本文整理汇总了Python中flickrapi.FlickrAPI.get_request_token方法的典型用法代码示例。如果您正苦于以下问题:Python FlickrAPI.get_request_token方法的具体用法?Python FlickrAPI.get_request_token怎么用?Python FlickrAPI.get_request_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flickrapi.FlickrAPI
的用法示例。
在下文中一共展示了FlickrAPI.get_request_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_flickr
# 需要导入模块: from flickrapi import FlickrAPI [as 别名]
# 或者: from flickrapi.FlickrAPI import get_request_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_request_token [as 别名]
from flickrapi import FlickrAPI
class keys:
apikey = u'a233c66549c9fb5e40a68c1ae156b370'
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')