从Twitter检索电子邮件? Mvc4 C#

时间:2013-11-25 12:37:04

标签: c# asp.net-mvc-4 twitter linq-to-twitter

有没有机会从Twitter用户那里检索电子邮件? 我在C#Mvc4中使用LinqToTwitter Nuget。

如果您知道任何事情,请:)!

2 个答案:

答案 0 :(得分:1)

这就是我在c#

中的表现
try
{
    // we need to call the user authentication credetials verification api )(using linqtotwitter library) to get the user email
    var authTwitter = new SingleUserAuthorizer
    {
        CredentialStore = new SingleUserInMemoryCredentialStore
        {
            ConsumerKey = TwConsumerKey,
            ConsumerSecret = TwConsumerSecret,
            OAuthToken = accessTokenClaim.Value,
            OAuthTokenSecret = accessTokenSecretClaim.Value,
            UserID = ulong.Parse(loginInfo.Login.ProviderKey),
            ScreenName = loginInfo.DefaultUserName
        }
    };

    await authTwitter.AuthorizeAsync();

    // call verify credentials api
    var twitterCtx = new TwitterContext(authTwitter);
    var verifyResponse =
          await
              (from acct in twitterCtx.Account
               where (acct.Type == AccountType.VerifyCredentials) && (acct.IncludeEmail == true)
               select acct)
              .SingleOrDefaultAsync();

    if (verifyResponse != null && verifyResponse.User != null)
    {
        User twitterUser = verifyResponse.User;

        //assign email to existing authentication object
        loginInfo.Email = twitterUser.Email;

    }
}
catch (TwitterQueryException tqe)
{

}

http://www.bigbrainintelligence.com/Post/get-users-email-address-from-twitter-oauth-ap

答案 1 :(得分:0)

Twitter API中没有该数据点。你可以看到这里有什么:

https://dev.twitter.com/docs/platform-objects/users

因此,LINQ to Twitter也无法提供电子邮件。