1

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

请如果你知道什么:)!

4

2 回答 2

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

于 2016-05-19T14:36:42.897 回答
0

该数据点在 Twitter API 中不可用。您可以在此处查看可用的内容:

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

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

于 2013-11-25T15:55:20.820 回答