using the twitter gem I want to get all the followers of the authenticated user. I only get the followers of the registered twitter id for the application though.
I have a twitter.rb in the initializers which uses the consumer key/secret of the registered app on twitter
Twitter.configure do |config|
config.consumer_key = '****'
config.consumer_secret = '****'
end
When you login you do so via Devise. Then in the user profile the user can authenticate with Twitter and at that point I store the token and secret.
def create
auth = request.env["omniauth.auth"]
currentAuthentication = Authentication.find_by_provider_and_uid(auth['provider'], auth['uid'])
if currentAuthentication
flash[:notice] = "Logged in successfully."
else
current_user.authentications.create(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'], :secret => auth['credentials']['secret'])
flash[:notice] = "Authentication successful."
end
redirect_to authentications_url
end
Then at a later stage I authenticate that user with the information I stored and want to get his followers.
def getwords
# authenticate at twitter
authenticationDetails = current_user.authentications.first()
wordClient = Twitter::Client.new(
:oauth_token => authenticationDetails.token,
:oauth_token_secret => authenticationDetails.secret
)
# get the users followers
#wordClient.update("I'm tweeting using the Twitter Gem.")
cursor = "-1"
followerIds = []
while cursor != 0 do
followers = wordClient.follower_ids
cursor = followers.next_cursor
followerIds+= followers.ids
sleep(2)
end
return followerIds
end
When I do wordClient.update I sent a tweet out from the registered application, and I also get the followers of the registered application.
I was expecting to sent out a tweet and get the followers of the authenticated user? Where am I going wrong? All examples I've been able to find are on the bases of twittering with one single user.