1
我试图找到所有可能的条目在twitter上的特定关键字,但使用下面的代码只有拳头100返回。搜索在第二次迭代中返回null。谁能告诉我我做错了什么?linqtotwitter找到100多个搜索
public async void SearchForTweets()
{
const int maxNumberToFind = 100;
const string whatToFind = "iphone";
ulong lastId = 0;
var total = 0;
int count;
do
{
var id = lastId;
// Get the first 100 records, or the first 100 whose ID is less than the previous set
var searchResponse =
await
(from search in _twitterCtx.Search
where search.Type == SearchType.Search &&
search.Query == whatToFind &&
search.Count == maxNumberToFind &&
(id == 0 || search.MaxID < id)
select search)
.SingleOrDefaultAsync();
// Only if we find something
if (searchResponse != null && searchResponse.Statuses != null)
{
// Out put each tweet found
searchResponse.Statuses.ForEach(tweet =>
Console.WriteLine(
"{4} ID: {3} Created: {2} User: {0}, Tweet: {1}",
tweet.User.ScreenNameResponse,
tweet.Text,
tweet.CreatedAt,
tweet.StatusID,
DateTime.Now.ToLongTimeString()));
// Take a note of how many we found, and keep a running total
count = searchResponse.Statuses.Count;
total += count;
// What is the ID of the oldest found (Used to limit the next search)
lastId = searchResponse.Statuses.Min(x => x.StatusID);
}
else
{
count = 0;
}
} while (count == maxNumberToFind); // Until we find less than 100
Console.Out.WriteLine("total = {0}", total);
}
的可能的复制[如何让主题标记所有鸣叫使用LinqToTwitter(http://stackoverflow.com/questions/34943 598 /如何到获得,所有微博上,使用-linqtotwitter包括hashtag - ) –