sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.59k stars 1.31k forks source link

Facing a strange problem with client.follow #777

Closed tomarsamar closed 8 years ago

tomarsamar commented 8 years ago

Twitter follow api https://api.twitter.com/1.1/friendships/create.json, does't have a hard rate limit but twitter can restrict the user if user follows hundereds of tweeps, when I used client.follow(connection_id) then it stops after following 15 tweeps and throw exception: rate limit exceeded, this should not happen as with testing twitter account I followed only 50 tweeps. I planned to look closely and inserted some debug 'puts' at various places in the twitter and faraday gem, what I found from debug that before calling twitter follow api client.follow calls twitter friends/ids.json api and this api has rate limit of 15 calls per 15 minutes and thats why client.follow throw rate limit exception after following 15 tweeps, here is debug output

lib_ _-bash_ _204x62
  May be I am missing something here, here is my test code
 require 'twitter'

class FolowTest
    def follow(connection_id, accedd_token, access_token_secret)

      client = Twitter::REST::Client.new do |config|
        config.consumer_key = 'XXXXXXXXXXXXXX'
        config.consumer_secret     = 'XXXXXXXXXXXXXX'
        config.access_token        = 'XXXXXXXXXXXXXXX'
        config.access_token_secret = 'XXXXXXXXXXXXXX'
      end

      client.follow(connection_id)
  end
end
tomarsamar commented 8 years ago

closing this issue as it's already resolved here --> https://github.com/sferik/twitter/issues/534