我正在努力让我的应用程序显示来自我的应用程序的提要时间线。到目前为止,我已经使用了 oauth-plugin、oauth 和 twitter gems(用于 rails3)来获得授权。这工作得很好。
现在,当我尝试连接时,我很挣扎。
我最终得到一个错误:
uninitialized constant Twitter::OAuth
已检查我没有调用 twitter 的其他操作(如此处的另一篇文章中所述)。但到目前为止,没有运气。
希望有人能帮忙!
- 编辑 -
我忘了提到我正在使用 Devise 来验证我的用户。已尝试插入:
require 'twitter'
但是还是没有成功。。
-- 编辑二 --
在 twitter gem git 网站上找到了关于在 1.0 版中折旧的解决方案。
我现在已将 twitter_token.rb 文件中的代码替换为:
def 客户端,除非 @client
@twitter_oauth=Twitter::Client.new(:TwitterToken.consumer.key,:TwitterToken.consumer.secret)
@twitter_oauth.authorize_from_access(token,secret)
@client=Twitter::Base.new(@twitter_oauth)
end
哪个摆脱了那个错误,但现在又导致另一个:(
undefined method `consumer' for :TwitterToken:Symbol
我也试过这个:
def client
unless @client
@twitter_oauth=Twitter::Client.new(:oauth_token =>'TwitterToken.consumer.key', :oauth_token_secret=>'TwitterToken.consumer.secret')
@twitter_oauth.authorize_from_access token,secret
@client=Twitter::Base.new(@twitter_oauth)
end
这给出了以下错误:
undefined method `authorize_from_access' for #<Twitter::Client:0x00000102da1530>
有任何想法吗?我要疯了!