Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

Commented Issue: Search.SearchTweets is not working with #tags [2187]

$
0
0
HI Tweetinvi,


I'm trying to get all tweets for a particular #tag & it works if that #tag is trending on twitter,but if I use a custom #tag,which has only one or two tweets,its throwing errors(Object reference not set...)?
This is my code sample:

TwitterCredentials.SetCredentials("AccessToken", ".AccessSecret","ConsumerKey","ConsumerSecret");
var tokenRateLimits = RateLimit.GetCurrentCredentialsRateLimits();
if(okenRateLimits.ApplicationRateLimitStatusLimit.Remaining>0)
{
var searchParameter = Search.GenerateSearchTweetParameter("#MYCUSTOMHASHTAG");
var tweets = Search.SearchTweets(searchParameter);// getting error here
var count=tweets.Count;
}

I've tried with twitter api & it's returning the tweets:
https://api.twitter.com/1.1/search/tweets.json?q=%23MYCUSTOMHASHTAG;



-Regards,
Vikram
Comments: ** Comment from web user: linvi **

Hi there,

Doing a search of a 1000 objects is quite risky as it might use a lot of token from the rate-limitation.
The reason is that twitter does not send complete result sets. It means that a single query could use 30 tokens instead of 10 as you would expect.

If you need to get ALL the tweets from a specific tag you do not want to use search but the FilteredStream.

``` c#
var fs = Stream.CreateFilteredStream();
fs.AddTrack("#tag");
fs.MatchingTweetReceived += (sender, args) =>
{
var tweet = args.Tweet;
// Do your code logic
};
fs.StartStreamMatchingAllConditions();
```

Please let me know if this answers your problem.
Linvi


Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>