我正在将 twitter gem 用于 Rails 应用程序,以便我可以将我的博客文章自动更新到我的 twitter 提要中。
我按照gem 自述文件的说明,将其放入 config/initializers/twitter.rb 文件中
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
将这些变量更新到 Heroku,在我的 twitter 帐户下注册我的应用程序,为该帐户提供读取、写入和直接访问权限,然后尝试通过 heroku 控制台进行更新,如下所示:
Twitter.update("Testing Twitter integration")
不幸的是,我收到此错误:
Twitter::Error::Unauthorized: Could not authenticate you
(其次是这些可能无用的细节):
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/response/raise_error.rb:21:in `on_complete'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:9:in `block in call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:63:in `on_complete'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/response.rb:8:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/request/url_encoded.rb:14:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/request/multipart.rb:13:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/request/multipart_with_file.rb:14:in `call'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/connection.rb:247:in `run_request'
from /app/vendor/bundle/ruby/1.9.1/gems/faraday-0.8.6/lib/faraday/connection.rb:112:in `post'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/client.rb:81:in `request'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/client.rb:70:in `post'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/api/utils.rb:82:in `object_from_response'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter/api/tweets.rb:129:in `update'
from /app/vendor/bundle/ruby/1.9.1/gems/twitter-4.5.0/lib/twitter.rb:52:in `method_missing'
from (irb):2
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):003:0>
Twitter 肯定至少部分地对我进行了身份验证,因为早些时候,当我没有切换到读/写时,它抱怨说
Twitter::Error::Unauthorized: Error processing your OAuth request: Read-only application cannot POST
(为了解决这个问题,我编辑了我的设置并重置了我的 OAuth 密钥)。
我用谷歌搜索过,但我没有找到其他处于相同情况的人。想知道我是否做错了什么,或者我是否只需要等待一下。
有任何想法吗?