0
我開始嘗試使用Linq到Twitter庫來查詢一些twitter數據。我有如下功能:如何在UAP中使用LinqToTwitter?
public static async Task<List<Status>> GetTweets(TwitterContext context, string searchQuery, int count = 15)
{
var searchResult = await
(from search in context.Search
where search.Type == SearchType.Search &&
search.Query == searchQuery &&
search.IncludeEntities == true &&
search.Count == count
select search)
.SingleOrDefaultAsync();
return searchResult.Statuses;
}
並在控制檯應用程序的功能,我創建調用這個函數是這樣的:
IAuthorizer authorizer = new ApplicationOnlyAuthorizer
{
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = consumerKey,
ConsumerSecret = consumerSecret,
}
};
authorizer.AuthorizeAsync().Wait();
TwitterContext context = new TwitterContext(authorizer);
List<Status> statuses = GetTweets(context, "#hashtag", 50).Result;
這完美的作品。但是,如果我將其遷移到通用Windows應用程序,那麼它永遠掛在List<Status> statuses = GetTweets(context, "#hashtag", 50).Result;
。沒有異常發生,什麼也沒有顯示,沒有任何回報。我用錯了嗎?