简体   繁体   English

使用Twitter API获取用户电子邮件

[英]Getting user email using Twitter API

I'm trying to get user email using twitter API. 我正在尝试使用Twitter API获得用户电子邮件。 My App is in whitelist and I received response about user using users/show.json without any problems: Request URL: 我的应用程序处于白名单中,我收到有关使用users / show.json的用户的响应,没有任何问题:请求URL:

https://api.twitter.com/1.1/users/show.json?oauth_consumer_key=xxx&oauth_nonce=xxx&oauth_signature=xx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1466232185&oauth_token=xxx&oauth_version=1.0&screen_name=xxx https://api.twitter.com/1.1/users/show.json?oauth_consumer_key=xxx&oauth_nonce=xxx&oauth_signature=xx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1466232185&oauth_token=xxx&oauth_version=1.0&screen_name=xxx

But when I'm trying to use verify_credentials.json with include_email=true I'm getting this error: 但是,当我尝试使用带有include_email=true verify_credentials.json ,我得到了这个错误:

HTTP request failed! HTTP请求失败! HTTP/1.0 401 Authorization Required 需要HTTP / 1.0 401授权

Request URL (almost the same as above): 请求网址(与上面几乎相同):

https://api.twitter.com/1.1/users/verify_credentials.json?oauth_consumer_key=xxx&oauth_nonce=xxx&oauth_signature=xx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1466232185&oauth_token=xxx&oauth_version=1.0&include_email=true https://api.twitter.com/1.1/users/verify_credentials.json?oauth_consumer_key=xxx&oauth_nonce=xxx&oauth_signature=xx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1466232185&oauth_token=xxx&oauth_version=1.0&include_email=o

As described here in the twitter documentation I'm getting 401 error if authentication was unsuccessful. Twitter文档中的此处所述,如果身份验证不成功,我将收到401 error But why when I'm accessing show.json I'm getting successfull response and when I'm trying to acccess verify_credentials I'm getting 401 error? 但是,为什么当我访问show.json获得成功的响应,而当我尝试访问verify_credentials得到401错误?

Can anyone explain what I am doing wrong? 谁能解释我在做什么错?

  1. did you white list your app? 您是否将应用列入白名单?

not all apps are able to fetch the user's email but only the ones which already been white listed by twitter. 并非所有的应用程序都能够获取用户的电子邮件,而只有Twitter已白名单的应用程序能够获取。 if not go to your app in apps.twitter.com and authorize it 如果没有,请访问apps.twitter.com中的应用并授权

  1. did you use the authorize edge on the user again? 您是否再次使用了用户的授权权限?

after activating the email fetch in apps.twitter.com you need to reauthorize the user to be able to fetch the email from him. 在apps.twitter.com中激活电子邮件提取后,您需要重新授权用户才能从他那里提取电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM