gpt4 book ai didi

python - 验证 Twitter 时无法收到 Twitter 电子邮件

转载 作者:行者123 更新时间:2023-12-01 06:40:49 24 4
gpt4 key购买 nike

我正在使用 Oauth1Session 来验证 Twitter 并尝试获取用户的电子邮件信息。实际上,应用程序已成功获取用户信息,但不包括电子邮件信息。如何通过 account/verify_credentials 获取电子邮件信息。

我的代码:

    access_token_url = 'https://api.twitter.com/oauth/access_token'
protected_url = 'https://api.twitter.com/1.1/account/verify_credentials.json'

oauth_token = request.args.get('oauth_token')
oauth_verifier = request.args.get('oauth_verifier')

twitter = OAuth1Session(
client_id,
client_secret,
oauth_token,
oauth_verifier
)

response = twitter.post(
access_token_url,
params={'oauth_verifier': oauth_verifier}
)
access_token = dict(parse_qsl(response.content.decode("utf-8")))

oauth = OAuth1Session(
client_id,
client_secret=client_secret,
resource_owner_key=access_token["oauth_token"],
resource_owner_secret=access_token["oauth_token_secret"]
)

params = {"include_email": True}

response = oauth.get(protected_url, params = params)
user_info = response.json()

用户信息

{'id': xxxxxxxxx, 'id_str': 'xxxxxxxx', 'name': 'xxxxxxxx', 'screen_name': 'xxxxxxxxxx', 'location': 'xxxxxxxxxxxxx', 'description': 'xxxxxxxxxxxx', 'url': None, 'entities': {'description': {'urls': []}}, 'protected': False, 'followers_count': xxx, 'friends_count': xx, 'listed_count': xx, 'created_at': 'Thu Aug 27 14:16:29 +0000 2015', 'favourites_count': xxxx, 'utc_offset': None, 'time_zone': None, 'geo_enabled': True, 'verified': False, 'statuses_count': xxxxx, 'lang': None, 'status': {'created_at': 'Sun Dec 22 10:11:00 +0000 2019', 'id': xxxxxxxxxxx, 'id_str': 'xxxxxxxxxxx', 'text': 'xxxxxxxxxxxxxxx', 'truncated': False, 'entities': {'hashtags': [], 'symbols': [], 'user_mentions': [], 'urls': []}, 'source': 'Twitter for iPhone', 'in_reply_to_status_id': None, 'in_reply_to_status_id_str': None, 'in_reply_to_user_id': None, 'in_reply_to_user_id_str': None, 'in_reply_to_screen_name': None, 'geo': None, 'coordinates': None, 'place': None, 'contributors': None, 'is_quote_status': False, 'retweet_count': 0, 'favorite_count': 2, 'favorited': False, 'retweeted': False, 'lang': 'ja'}, 'contributors_enabled': False, 'is_translator': False, 'is_translation_enabled': False, 'profile_background_color': '000000', 'profile_background_image_url': 'xxxxxxxxxxxxxxxxx', 'profile_background_image_url_https': 'xxxxxxxxxxxxxxxx', 'profile_background_tile': False, 'profile_image_url': 'xxxxxxxxxxxxxxxx', 'profile_image_url_https': 'xxxxxxxxxxxxxxxxxxx', 'profile_banner_url': 'xxxxxxxxxxxxxxxxxx', 'profile_link_color': 'DD2E44', 'profile_sidebar_border_color': '000000', 'profile_sidebar_fill_color': '000000', 'profile_text_color': '000000', 'profile_use_background_image': False, 'has_extended_profile': False, 'default_profile': False, 'default_profile_image': False, 'can_media_tag': False, 'followed_by': False, 'following': False, 'follow_request_sent': False, 'notifications': False, 'translator_type': 'none', 'suspended': False, 'needs_phone_verification': False}

但不包括电子邮件...

最佳答案

我已经更新了参数:

params = {"include_email": "true"}

关于python - 验证 Twitter 时无法收到 Twitter 电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59462405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com