I am facing a strange TooManyRequests error. it is strange because when I use rails console and request for example [list_timeline(40906334)] more than 15 times < 180 times it works without the error.
however, when I do the same thing from the controller it raise the error. I am suspecting that the reason is because of the creation of new client each time since in the console I created it only once and used it several times.
This is the console code:
@twitter_user = Twitter::Client.new(:oauth_token =>'1234567',:oauth_token_secret => '1234567')
@twitter_user.list_timeline(40906994)
@twitter_user.list_timeline(87506074)
@twitter_user.list_timeline(43344574)
This is the server code:
in the user class
def twitter
if provider == "twitter"
@twitter ||= Twitter::Client.new(:oauth_token => token, :oauth_token_secret => secret)
end
end
in the controller for each call
current_user.twitter.list_timeline(params[:list_id])