0

在使用 Linq2Twitter v3.0.2 时遇到一些问题。在我调用 SingleOrDefault 的行之后,它无限期地挂起。如果您需要更多信息,请告诉我。在此先感谢您的帮助。

var auth = new SingleUserAuthorizer
{
    CredentialStore = new SingleUserInMemoryCredentialStore()
    {
    ConsumerKey = MyConsumerKey,
    ConsumerSecret = MyConsumerSecret,
    AccessToken = MyAccessToken,
    AccessTokenSecret = MyAccessTokenSecret
    }
};

var twtrContext = new TwitterContext(auth);

var results =
    from search in twtrContext.Search
    where search.Type == SearchType.Search &&
          search.Query == "Obama" &&
          search.Count == 10
    select search.Statuses;

var tweets = results.SingleOrDefault();
4

1 回答 1

1

LINQ to Twitter v3.0 是异步的。您应该像这样更改您的查询:

        var auth = new SingleUserAuthorizer
        {
            CredentialStore = new SingleUserInMemoryCredentialStore()
            {
                ConsumerKey = MyConsumerKey,
                ConsumerSecret = MyConsumerSecret,
                AccessToken = MyAccessToken,
                AccessTokenSecret = MyAccessTokenSecret
            }
        };

        var twtrContext = new TwitterContext(auth);

        var searchResponse =
            await
            (from search in twitterCtx.Search
             where search.Type == SearchType.Search &&
                   search.Query == "Obama" &&
                   search.Count == 10
             select search)
            .SingleOrDefaultAsync();
于 2014-03-21T01:51:56.297 回答