2016-06-10 136 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

相關問題