當前位置: 首頁>>代碼示例>>Python>>正文


Python FlickrAPI.token_valid方法代碼示例

本文整理匯總了Python中flickrapi.FlickrAPI.token_valid方法的典型用法代碼示例。如果您正苦於以下問題:Python FlickrAPI.token_valid方法的具體用法?Python FlickrAPI.token_valid怎麽用?Python FlickrAPI.token_valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flickrapi.FlickrAPI的用法示例。


在下文中一共展示了FlickrAPI.token_valid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_flickr

# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import token_valid [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
開發者ID:jgsogo,項目名稱:facematch,代碼行數:15,代碼來源:down_flickr_album.py

示例2: print

# 需要導入模塊: from flickrapi import FlickrAPI [as 別名]
# 或者: from flickrapi.FlickrAPI import token_valid [as 別名]
logging.basicConfig(level=logging.INFO)

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)
開發者ID:SpootDev,項目名稱:flickrapi,代碼行數:32,代碼來源:oauth_test_3-oob.py


注:本文中的flickrapi.FlickrAPI.token_valid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。