我正在使用 twitter gem 和 amniauth 来获取用户的推文并将它们显示在我的主页上。但是当我尝试从命令行获取推文时,我收到了“错误的身份验证数据”错误。
宝石文件:
gem 'omniauth'
gem 'omniauth-twitter'
gem 'twitter'
config/initializers 中的 Twitter.rb:
Twitter.configure do |config|
config.consumer_key = 'key'
config.consumer_secret = 'secret'
config.oauth_token = 'token'
config.oauth_token_secret = 'secret'
end
配置/初始化程序中的omniauth.rb:
require 'omniauth-twitter'
config.omniauth :twitter, 'key', 'secret'
我已经仔细检查了我的密钥和密码,但我无法让它运行。我正在使用狂欢。这是错误:
irb(main):001:0> require 'twitter'
=> true
irb(main):002:0> Twitter.user_timeline(213747670)
Twitter::Error::BadRequest: Bad Authentication data
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/response/raise_error.rb:21:in `on_complete'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:9:in `block in call'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:63:in `on_complete'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request/url_encoded.rb:14:in `call'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request/multipart.rb:13:in `call'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/request/multipart_with_file.rb:14:in `call'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:247:in `run_request'
from /usr/local/lib64/ruby/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:100:in `get'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/client.rb:81:in `request'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/client.rb:64:in `get'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/api/utils.rb:51:in `objects_from_response'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/api/utils.rb:42:in `objects_from_response_with_user'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter/api/timelines.rb:53:in `user_timeline'
from /usr/local/lib64/ruby/gems/1.9.1/gems/twitter-4.6.2/lib/twitter.rb:52:in `method_missing'
from (irb):2
谢谢你的帮助。