2016-06-10 140 views
1

我现在在Twitter上将我的应用列入白名单,以便能够在登录时获得他们的电子邮件地址,并且使用TweetSharp作为我的图书馆来验证用户身份,看到一种方式来传递参数来请求使用该库的电子邮件地址。我知道这是一个旧图书馆,我认为请求用户的电子邮件是相对较新的,所以也许不可能不通过源代码挖掘,更新它并重新编译程序集?使用C#和OAuth从Twitter获取用户的电子邮件地址

如果有人能用TweetSharp完成此操作,请告诉我。

TIA

回答

2

通过TweetSharp的来源了一点,我得到了相当层层叠叠失去了在层挖掘后...就像是试图寻找一个针在20干草堆。我很欣赏Tweetinvi Linvi的链接,但我决定在今天晚上锻炼我的大脑,看看我是否可以从头开始编写它。

我花了一些时间了解我可以在Twitter上找到什么,以及他们做OAuth的方式超越时髦。然后我找到了一个处理OAuth的PHP解决方案,并稍微调整了一下以使其返回电子邮件地址。有了这个,我将PHP翻译成C#,并将它们全部用于我自己的家庭解决方案。

我只是张贴在这里我工作的解决方案:http://www.burritostand.com/log-in-to-twitter-with-oauth-and-c-sharp-and-get-twitter-user-email

它需要一些重大的重构,使之成为生产价值的实现,但我认为,因为它打破了不同的过程很清楚这可能是有用的人。希望别人可以利用它。

的关键部分(用于检索电子邮件)是TwitterClient的类,在参数表:

 TwitterUrls TwitterUrls = new TwitterUrls("https://api.twitter.com/1.1/account/verify_credentials.json"); 
     List<KeyValuePair<string, string>> Parameters = new List<KeyValuePair<string, string>>(); 
     Parameters.Add(new KeyValuePair<string, string>("include_email", "true")); // this is the important part for getting the email returned 
     Parameters.Add(new KeyValuePair<string, string>("oauth_consumer_key", ConsumerKey)); 
     Parameters.Add(new KeyValuePair<string, string>("oauth_nonce", Nonce)); 
     Parameters.Add(new KeyValuePair<string, string>("oauth_signature_method", "HMAC-SHA1")); 
     Parameters.Add(new KeyValuePair<string, string>("oauth_timestamp", timestamp)); 
     Parameters.Add(new KeyValuePair<string, string>("oauth_token", dict["oauth_token"])); 
     Parameters.Add(new KeyValuePair<string, string>("oauth_version", OAuthVersion)); 

我很欣赏的答案,我也有一些有趣回去PHP今晚......一直一个looooong时间:)

1

Tweetinvi支持电子邮件。

var authenticatedUser = User.GetAuthenticatedUser(); 
var email = authenticatedUser.Email; 

您可以在github这里的项目:https://github.com/linvi/tweetinvi

相关问题