获取LinqTotWitter的推文



我正在尝试从Twitter获取推文,但它与我不正常,这是代码:

var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore()
                {
                    ConsumerKey = ConfigurationManager.AppSettings["***"],
                    ConsumerSecret = ConfigurationManager.AppSettings["***"],
                    AccessToken = ConfigurationManager.AppSettings["***"],
                    AccessTokenSecret = ConfigurationManager.AppSettings["***"]
                }
            };
var context = new TwitterContext(auth);
var tweets =
    from tw in context.Status
    where
        tw.Type == StatusType.User &&
        tw.ScreenName == "***"
    select tw;
// handle exceptions, twitter service might be down
try
{
    // map to list
    tweets
        .Take(3)
        .Select(t =>
            new Tweets
            {
                //Username = t.ScreenName,
                //FullName = t.User.Name,
                TweetText = t.Text,
                //FormattedText = ParseTweet(t.Text)
            })
        .ToList();
}
catch (Exception) { }

每当我尝试阅读推文时,它都会失败,例外是

LinqToTwitter.TwitterQueryException: Bad Authentication data

,但我确定凭据是正确的。

,还可以阅读另一个Twitter帐户的帖子吗?像公司帐户或庆祝帐户?

linq to twitter是异步的,因此您应该这样更改查询:

var tweets =
    await
    (from tw in context.Status
     where
        tw.Type == StatusType.User &&
     tw.ScreenName == "***"
     select tw)
    .ToListAsync();

此外,在实例化AUTH并检查凭据以确保您填充它们后,点击点。

最新更新