我试图在使用fb_graph(2.6.0)创业板创建内容时共享facebook,
在尝试时,我会发现以下错误:
app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.get_access_token
user = FbGraph::User.me(access_token).fetch
在开发控制台中
=> 377095675642525|X3SyfucEUnahEEFAFwkO_cFXRyc
1.9.3p194 :005 > user = FbGraph::User.me(access_token).fetch
LoadError: cannot load such file -- {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:234:in `load'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:234:in `block in load'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:223:in `load_dependency'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.10/lib/active_support/dependencies.rb:234:in `load'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/fb_graph-2.6.0/lib/fb_graph/node.rb:138:in `handle_response'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/fb_graph-2.6.0/lib/fb_graph/node.rb:49:in `get'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/fb_graph-2.6.0/lib/fb_graph/node.rb:19:in `fetch'
from (irb):5
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.10/lib/rails/commands/console.rb:45:in `start'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.10/lib/rails/commands/console.rb:8:in `start'
from /home/love/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.1.10/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
在Heroku日志中:
Started GET "/facebook/callback?code=AQDccVXzo55GpSCCnr0vXKb2xpHFtJ8E_Eb-3AfA6Wcx5G1QEMHr4vNuH0366tGYVFepTuDZv2Z9_BLeXdMRNcLtfg1N3mz8rbTZowblEeGqg9Ls7R7X7P2GiuyFPJa0PTric7gjE8cZ3olRyP27otiGfzWQ4REoqS-BFsH4BwyfyZSiZxoQ0PPDUmlxeve4Cn9qAKzC2sYmEEbdTcPo2quu" for 122.164.241.1 at 2013-02-26 05:42:55 +0000
2013-02-26T05:42:56+00:00 app[web.1]: #<FbGraph::Auth:0x00000004e1bbb8 @client=# <Rack::OAuth2::Client:0x00000004e19b38 @identifier=188451457933295, @secret="13d6158a6ebe35a115bcae7f0ec14826", @redirect_uri=nil, @scheme=nil, @host="graph.facebook.com", @port=nil, @authorization_endpoint="/oauth/authorize", @token_endpoint="/oauth/access_token", @grant=# <Rack::OAuth2::Client::Grant::ClientCredentials:0x00000005484e28>>>
app/controllers/facebooks_controller.rb:29:in `create'
2013-02-26T05:42:56+00:00 heroku[router]: at=info method=GET path=/facebook/callback?code=AQDccVXzo55GpSCCnr0vXKb2xpHFtJ8E_Eb-3AfA6Wcx5G1QEMHr4vNuH0366tGYVFepTuDZv2Z9_BLeXdMRNcLtfg1N3mz8rbTZowblEeGqg9Ls7R7X7P2GiuyFPJa0PTric7gjE8cZ3olRyP27otiGfzWQ4REoqS-BFsH4BwyfyZSiZxoQ0PPDUmlxeve4Cn9qAKzC2sYmEEbdTcPo2quu host=x.y.com fwd="122.164.241.1" dyno=web.1 queue=0 wait=0ms connect=2ms service=431ms status=500 bytes=0
单击facebook登录后,我在浏览器中得到以下错误:
Server error
The website encountered an error while retrieving http://x.y.com/facebook/callback?code=AQAGIeV8GLZWMI98eauog2eTDq7jeXBEhBSDg3izqBBjS6mVN3y5tgTSGcagmAqMTYHyB_EJArN834cglLjBL4yHDQHlEaD7j7wSmSPN43hZXQhCHJTbvP0HHJPBwAiNCCZYOiP2jpLLAyznLoufwvN-6p6dLgjup8WPtRyEeUspv94m-O5lC146JHNvWFUvCHaPaQ2wPWyfmh5C89mR2G0R#_=_. It may be down for maintenance or configured incorrectly.
发布于 2013-02-26 09:06:17
从您的问题来看,您似乎正在使用应用程序访问令牌来访问用户信息。重新进入
FbGraph::InvalidRequest: OAuthException :: An active access token must be used to query information about the current user.
然而,您应该使用用户的访问令牌获取配置文件信息或在您的墙上张贴。
如果您正尝试使用Facebook进行全方位登录,下面是一个很好的入门教程:http://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/
当使用图表时,您应该有用户的访问令牌来执行任何进一步的操作,例如更新状态(墙帖)
这需要一个访问令牌,您应该在为该用户验证应用程序时保存该令牌。
你可以做
me = FbGraph::User.me(ACCESS_TOKEN)
me.feed!(
:message => 'Updating via FbGraph',
:picture => 'https://graph.facebook.com/matake/picture',
:link => 'https://github.com/nov/fb_graph',
:name => 'FbGraph',
:description => 'A Ruby wrapper for Facebook Graph API'
)
注意:这需要扩展权限,您可以在作用域属性中指定这些权限。
Rails.application.config.middleware.use OmniAuth::Builder do
# The following is for facebook
provider :facebook, [APP ID], [SECRET KEY], {:scope => 'email, read_stream, read_friendlists, friends_likes, friends_status, offline_access'}
# If you want to also configure for additional login services, they would be configured here.
end
https://stackoverflow.com/questions/15082583
复制相似问题