3

我想在通过 Twitter 进行身份验证后检索用户信息。为此,我使用 LINQ to Twitter 库。可以使用以下代码:

 var usersResponse =
            (from user in context.User
             where user.Type == UserType.Lookup &&
                   user.ScreenName == "MRade90"
             select user).ToList();

        var users =
           (from user in usersResponse
            select new User
            {
                Name = user.Identifier.ScreenName,
                StatusText = user.Status.Text,
                PictureUrl = new Uri(user.ProfileImageUrl)
            }).FirstOrDefault();

但这是硬编码的,ScreenName 设置为 MRade90。是否可以为当前经过身份验证的用户做同样的事情?

4

3 回答 3

2

我找到了。可以从 WinRtAuthorizer 类的 Credentials 属性访问当前用户凭据。例如,您可以在此处使用 ScreenName:

string screenName = auth.Credentials.ScreenName;
于 2012-12-07T22:39:28.483 回答
0

我在用

var users =
(from user in twitterCtx1.User where user.Type == UserType.Lookup && //user.UserID == list1 list1.Contains(user.UserID) select user) .ToList();

但是,我无法提取用户 ID 和工作。我可能出错的任何输入。

谢谢

于 2014-02-27T18:11:12.980 回答
0

我就是这样做的,

var auth = new SingleUserAuthorizer
                        {
                            CredentialStore = new SingleUserInMemoryCredentialStore
                            {
                                ConsumerKey = consumerKey,
                                ConsumerSecret = consumerSecret,
                                AccessToken = twitterToken.Token,
                                AccessTokenSecret = twitterToken.TokenSecret                                
                            }
                        };

var twitterCtx = new TwitterContext(auth);

  var acc = (from user in twitterCtx.Account where user.Type == AccountType.VerifyCredentials select user).FirstOrDefault();
于 2018-09-08T06:01:10.620 回答