在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();
答案 0 :(得分: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();