本文整理匯總了Python中flickrapi.FlickrAPI.get_access_token方法的典型用法代碼示例。如果您正苦於以下問題:Python FlickrAPI.get_access_token方法的具體用法?Python FlickrAPI.get_access_token怎麽用?Python FlickrAPI.get_access_token使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flickrapi.FlickrAPI
的用法示例。
在下文中一共展示了FlickrAPI.get_access_token方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_flickr
# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import get_access_token [as 別名]
def get_flickr(config_file):
config = ConfigParser.ConfigParser()
config.read(config_file)
api_key = config.get('Flickr', 'api_key')
api_secret = config.get('Flickr', 'api_secret')
api = FlickrAPI(api_key, api_secret, cache=True)
if not api.token_valid(perms=u'read'):
api.get_request_token(oauth_callback='oob')
authorize_url = api.auth_url(perms=u'read')
verifier = unicode(raw_input('Verifier code for %s:' % authorize_url))
api.get_access_token(verifier)
return api
示例2: print
# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import get_access_token [as 別名]
apisecret = u'03fbb3ea705fe096'
print('Creating FlickrAPI object')
flickr = FlickrAPI(keys.apikey, keys.apisecret)
# ------------------------------------------------------------------------------
print('Step 1: authenticate')
if not flickr.token_valid(perms='read'):
# Get a request token
flickr.get_request_token(oauth_callback='oob')
# Open a browser at the authentication URL. Do this however
# you want, as long as the user visits that URL.
authorize_url = flickr.auth_url(perms='read')
webbrowser.open_new_tab(authorize_url)
# Get the verifier code from the user. Do this however you
# want, as long as the user gives the application the code.
verifier = unicode(raw_input('Verifier code: '))
# Trade the request token for an access token
flickr.get_access_token(verifier)
# ------------------------------------------------------------------------------
print('Step 2: use Flickr')
resp = flickr.photos.getInfo(photo_id='7658567128')
ET.dump(resp)