Twitter“无法validation您”错误

我正在使用Twitter gem作为Rails应用程序,这样我就可以将我的博客post自动更新到我的twitter feed中。

我按照gem readme说明 ,将它放在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 `' from script/rails:6:in `require' from script/rails:6:in `'irb(main):003:0> 

Twitter至少部分地certificate了我,因为早些时候,当我没有切换到读/写时,它抱怨了

 Twitter::Error::Unauthorized: Error processing your OAuth request: Read-only application cannot POST 

(为了解决这个问题,我编辑了我的设置并重置了我的OAuth密钥)。

我用Google搜索过,但我没有幸运找到处于相同情况的其他人。 想知道我做错了什么,或者我是否只需要等一下。

有任何想法吗?

你提供了一个回调url吗?

这发生在Twitter的新更新,甚至我没有使用应用程序配置中的回调url,我遇到了同样的问题,直到我更新它,我结束添加

http://www.my-website.com/auth/twitter/callback

我甚至没有用于localhost开发,但之后就开始工作了。

否则请使用您的代码/gem更新twitter auth的问题,以及您在twitter上的设置,因为我们可以查看代码并告知您是否有任何问题