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

New Post: How to use the rate limiter

$
0
0
Hello,

I can't manage to understand how to use the rate limiter, and the documentation is too short for me.

I tried on purpose to send the same search query time after time to reach the limiter but can't understand how it is supposed to work.

Here is what I did :
public void SearchByDay()
{
var rateLimits = RateLimit.GetCurrentCredentialsRateLimits();
// Enable Tweetinvi RateLimit Handler
RateLimit.UseRateLimitAwaiter = true;
// Getting notified when your application is being stopped to wait for RateLimits to be available
RateLimit.QueryAwaitingForRateLimit += (sender, args) =>
{
Console.WriteLine("{0} is awaiting {1}ms for RateLimit to be available", args.Query, args.ResetInMilliseconds);
};
for (int i = 0; i <= 200; i++)
{
*** RUN A SEARCH QUERY HERE ***
rateLimits = RateLimit.GetCurrentCredentialsRateLimits();
}
}
The event wasn't triggered but now I can't access anything (i hope Twitter will not ban me for too long)

Anyway, can you provide a clearer way to test if I didn't exceeded the search limit and in case I reached the limit to wait for the counter reset.

Thanks a lot

Viewing all articles
Browse latest Browse all 4126

Trending Articles



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