I'm new to Twitter4R and Ruby on Rails. I'm using Ruby 1.9.2, Rails 3.1 and Twitter4R v0.7.0.
I'm trying to get my friends list from Twitter.
twitter = Twitter::Client.new(oauth_access: { key: token, secret: token_secret})
#these lines works fine.
twitter.status(:post, "POST TEST!!!")
twitter.friend(:add, "xxxx_jp")
#this line will cause ForbiddenError
friends = twitter.my(:friends)
I've checked the following site for information.
http://twitter4r.rubyforge.org/rdoc/Twitter/Client.html
Update
I now added config/initializers/twitter4r.rb
:
require 'twitter'
Twitter::Client.configure do |config|
config.oauth_consumer_token = consumer_key
config.oauth_consumer_secret = consumer_secret
end
When debugging, I see the consumer_key
and consumer_secret
in Twitter::Consumer
on debug window. But methods that require authentication like my(:friends)
do not work.
How do I avoid the ForbiddenError
?