我使用此代码,它可以获得用户喜欢的所有页面:
@user = session[:graph].get_object('me')
like = session[:graph].get_connections("me", "likes")
if !(like.to_s.include?('appid'))
redirect '/youneedlike'
end
它适用于我和我的伙伴,但有些用户有错误:他们总是被重定向,即使他们喜欢我们的页面。
怎么了?
答案 0 :(得分:2)
您的应用是否请求user_likes
permission?
或者,如果您的应用是画布应用,您可以使用signed_request
参数执行相同的操作:
# pseudocode
signed_request = decode signed_request()
if signed_request['page']['liked']:
# user liked page, do something cool
else:
# user doesn't like page. redirect somewhere to tell them why they should