Python – Tweepy 中的 API.configuration()
Twitter是一个流行的社交网络,用户在其中分享称为推文的消息。 Twitter 允许我们使用 Twitter API 或Tweepy挖掘任何用户的数据。数据将是从用户那里提取的推文。首先要做的是从 twitter 开发人员那里轻松获得每个用户可用的消费者密钥、消费者密钥、访问密钥和访问密钥。这些密钥将帮助 API 进行身份验证。
API.configuration()
Tweepy 模块中API
类的configuration()
方法用于获取 Twitter 使用的当前配置。
Syntax : API.configuration()
Parameters : None
Returns : an object of class dict
例子 :
# 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
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。