![](/img/trans.png)
[英]Get user's email from Twitter API for External Login Authentication ASP.NET MVC C#
[英]Get user's email address from Twitter with C# and OAuth
我現在在Twitter上將我的應用列入白名單,以便在他們登錄時能夠獲取他們的電子郵件地址,並且我使用TweetSharp作為我的庫來驗證用戶,但我沒有看到傳遞參數來請求他們的電子郵件的方法使用該庫的地址。 我知道這是一個舊庫,我認為請求用戶的電子郵件是相對較新的,所以也許只是不可能不挖掘源,更新它並重新編譯程序集?
如果有人能通過TweetSharp完成此任務,請告訴我。
TIA
在仔細挖掘了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 ...這是一個很棒的時間:)
Tweetinvi支持電子郵件。
var authenticatedUser = User.GetAuthenticatedUser();
var email = authenticatedUser.Email;
你可以在這里找到github上的項目: https : //github.com/linvi/tweetinvi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.