就在今天,我发现我的fbgraph实现已经开始返回一个导致内部服务器错误的400错误请求错误。Ruby on Rails - 检查控制器中的HTTP错误
控制器看起来像:
def fb
fbclient = FBGraph::Client.new(:client_id => 'ID', :secret_id => 'SECRET')
@fbname = fbclient.selection.user('129220333799040').feed.info!['data'][0].from.name
@fbmessage = fbclient.selection.user('129220333799040').feed.info!['data'][0].message
end
我如何调用我的看法是@fbname我已经收到了200个状态之前检查?
谢谢。
更新:以下德文M的建议,我已经关掉了上述行动,
def fb
fbclient = FBGraph::Client.new(:client_id => 'ID', :secret_id => 'SECRET')
begin
@fbname = fbclient.selection.user('129220333799040').feed.info!['data'][0].from.name
@fbmessage = fbclient.selection.user('129220333799040').feed.info!['data'][0].message
rescue
@fbname = "Facebook Account"
@fbmessage = "Facebook's API is a nightmare"
end
end
我想你应该先检查是否有用户权限(fbclient.selection.user('129220333799040'))你的调用中有太多的链可能会导致一个零或400错误的请求。尝试一步一步做,并添加适当的检查,当你找到哪个返回400 – corroded 2011-06-04 04:12:05
@腐蚀 - 谢谢。看起来api可能已经改变了。我仍然可以访问该用户,但试图访问该用户的Feed会导致400错误 – aperture 2011-06-04 04:23:31