0
我想在linqToTwitter用戶的網名來獲得用戶的電子郵件,我用這個代碼:如何在linqToTwitter中通過用戶的屏幕名稱獲取用戶的電子郵件?
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = "<Twitter consumer key>",
ConsumerSecret = "<Twitter consumer secret>",
AccessToken = "<Your access token>",
AccessTokenSecret = "<Your access token secret>"
}
};
var objTwitter = new TwitterContext(auth);
var objAccount = (from account in objTwitter.User
where account.Type == UserType.Show &&
account.ScreenName == sUser
select account);
var user = objAccount.SingleOrDefault();
Console.WriteLine("UserName : " + user.ScreenName);
Console.WriteLine("Name : " + user.Name);
Console.WriteLine("UserID : " + user.UserIDResponse);
Console.WriteLine("CreatedAt : " + user.CreatedAt);
Console.WriteLine("# of Friends : " + user.FriendsCount);
Console.WriteLine("# of Followers : " + user.FollowersCount);
Console.WriteLine("Email : " + user.Email);
Console.WriteLine("# of Tweets : " + user.StatusesCount);
Console.WriteLine("Photo URL : " + user.ProfileImageUrl);
Console.WriteLine("-------------------------------------------");
但用戶的電子郵件爲空。
也許電子郵件實際上是空的?如果在沒有拋出異常的情況下達到目標,它必須找到一條記錄來填充用戶對象,並且返回的記錄沒有關聯的電子郵件。 – user1666620
但我的推特帳戶有電子郵件 –
當你說電子郵件是'null',究竟發生了什麼?拋出異常嗎? 「objAccount」是否填充了「objTwitter.User」對象的集合?用戶是否被填充? – user1666620