Then using that get count of tweets which would be hash tag mention count. However just noticed your docs
"The maximum limit for this method seems to be 100. Nothing will go wrong if you specify a higher limit - the API will just not respond with more than 100 tweets per page."
Is there a different way of doing this to get what i need which is actual no of times that hash tag is mentioned.
Unfortunately I haven't come across anything in the API that works similar to what you're doing with Instagram.
At best you can use pagination to go beyond the first 100 tweets:
// Declare the initial options
TwitterSearchTweetOptions options = new TwitterSearchTweetOptions {
Query = "#umbraco",
Count = 50,
ResultType = TwitterSearchTweetResultType.Recent
};
// Get the first page of tweets
TwitterSearchTweetsResponse response = service.Search.GetTweets(options);
// Loop through the tweets
foreach (TwitterStatusMessage tweet in response.Body.Statuses) {
<pre>@tweet.Id: @tweet.Text</pre>
}
<hr />
// Update the options
options.MaxId = response.Body.Statuses.Last().Id - 1;
// Get the next page of tweets
response = service.Search.GetTweets(options);
// Loop through the tweets
foreach (TwitterStatusMessage tweet in response.Body.Statuses) {
<pre>@tweet.Id: @tweet.Text</pre>
}
But Twitter writes the following in their API documentation:
Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.
var twitterService = _skybrudClientFactory.SkyBrudTwitterService;
bool doQuery = true;
int hashTagCount = 0;
// Declare the initial options
var options = new TwitterSearchTweetOptions
{
Query = "#umbraco",
Count = 100,
IncludeEntities=false,
ResultType = TwitterSearchTweetResultType.Mixed
};
while (doQuery)
{
TwitterSearchTweetsResponse response = twitterService.Search.GetTweets(options);
if (response.Response.StatusCode == HttpStatusCode.OK && response.Body.Statuses != null && response.Body.Statuses.Any())
{
hashTagCount += response.Body.Statuses.Count();
options.MaxId = response.Body.Statuses.Last().Id - 1; //get next batch as we have limit to 100
}
else
{
doQuery = false;
}
}
Any suggestions improvements to code welcome ;-} I am including entities as I am not bothered I just want statuses with that hash tag, unless replies or re tweets would be ignored?
Hashtag mention count
Anders,
I am going to try and do
Then using that get count of tweets which would be hash tag mention count. However just noticed your docs
"The maximum limit for this method seems to be 100. Nothing will go wrong if you specify a higher limit - the API will just not respond with more than 100 tweets per page."
Is there a different way of doing this to get what i need which is actual no of times that hash tag is mentioned.
Regards
Ismail
Unfortunately I haven't come across anything in the API that works similar to what you're doing with Instagram.
At best you can use pagination to go beyond the first 100 tweets:
But Twitter writes the following in their API documentation:
Anders,
Excellent many thanks for that I now have:
Any suggestions improvements to code welcome ;-} I am including entities as I am not bothered I just want statuses with that hash tag, unless replies or re tweets would be ignored?
Regards
Ismail
I haven't tested your code, but it seems to be correct ;)
is working on a reply...