简体   繁体   中英

Difficulty getting all pages a user likes

I use this code, it get all pages the user likes:

@user = session[:graph].get_object('me')
    like = session[:graph].get_connections("me", "likes")
    if !(like.to_s.include?('appid'))
     redirect '/youneedlike'
    end

It's works for me and my mates, but some users have error: they are always redirected, even though they like our page.

What's wrong?

Does your app request the user_likes permission ?

Alternatively, if your app is a canvas app, you can use the signed_request parameter to do the same thing:

# 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM