当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Tweepy API.configuration()用法及代码示例


Twitter是一种流行的社交网络,用户在其中共享称为推文的消息。 Twitter允许我们使用Twitter API或Tweepy挖掘任何用户的数据。数据将是从用户提取的推文。首先要做的是从每个用户都可以轻松获得Twitter开发人员的使用者 key ,使用者 key ,访问 key 和访问 key 。这些 key 将帮助API进行身份验证。

API.configuration()

的configuration()方法APITweepy模块中的class用于获取Twitter使用的当前配置。

用法:API.configuration()

参数:

Returns:类字典的对象



例:

# import the module 
import tweepy 
  
# assign the values accordingly 
consumer_key = "" 
consumer_secret = "" 
access_token = "" 
access_token_secret = "" 
  
# authorization of consumer key and consumer secret 
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 
  
# set access to user's access key and access secret  
auth.set_access_token(access_token, access_token_secret) 
  
# calling the api  
api = tweepy.API(auth) 
  
# getting the configuration 
configuration = api.configuration() 
  
# printing the information 
for key, value in configuration.items():
    print(key  + ":" + str(value), end = "\n\n")

输出:

dm_text_character_limit:10000

characters_reserved_per_media:24

max_media_per_upload:1

non_username_paths:[‘about’, ‘account’, ‘accounts’, ‘activity’, ‘all’, ‘announcements’, ‘anywhere’, ‘api_rules’, ‘api_terms’, ‘apirules’, ‘apps’, ‘auth’, ‘badges’, ‘blog’, ‘business’, ‘buttons’, ‘contacts’, ‘devices’, ‘direct_messages’, ‘download’, ‘downloads’, ‘edit_announcements’, ‘faq’, ‘favorites’, ‘find_sources’, ‘find_users’, ‘followers’, ‘following’, ‘friend_request’, ‘friendrequest’, ‘friends’, ‘goodies’, ‘help’, ‘home’, ‘i’, ‘im_account’, ‘inbox’, ‘invitations’, ‘invite’, ‘jobs’, ‘list’, ‘login’, ‘logo’, ‘logout’, ‘me’, ‘mentions’, ‘messages’, ‘mockview’, ‘newtwitter’, ‘notifications’, ‘nudge’, ‘oauth’, ‘phoenix_search’, ‘positions’, ‘privacy’, ‘public_timeline’, ‘related_tweets’, ‘replies’, ‘retweeted_of_mine’, ‘retweets’, ‘retweets_by_others’, ‘rules’, ‘saved_searches’, ‘search’, ‘sent’, ‘sessions’, ‘settings’, ‘share’, ‘signup’, ‘signin’, ‘similar_to’, ‘statistics’, ‘terms’, ‘tos’, ‘translate’, ‘trends’, ‘tweetbutton’, ‘twttr’, ‘update_discoverability’, ‘users’, ‘welcome’, ‘who_to_follow’, ‘widgets’, ‘zendesk_auth’, ‘media_signup’]

photo_size_limit:3145728

photo_sizes:{‘thumb’:{‘h’:150, ‘resize’:‘crop’, ‘w’:150}, ‘small’:{‘h’:480, ‘resize’:‘fit’, ‘w’:340}, ‘medium’:{‘h’:1200, ‘resize’:‘fit’, ‘w’:600}, ‘large’:{‘h’:2048, ‘resize’:‘fit’, ‘w’:1024}}

short_url_length:23

short_url_length_https:23

相关用法


注:本文由纯净天空筛选整理自Yash_R大神的英文原创作品 Python – API.configuration() in Tweepy。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。