How to check if someone is liked my fanpage from my website?

微笑、不失礼 提交于 2020-04-16 04:24:51

问题


I want to check if a user liked my fan-page from my website and if he did i skip the step and if he didnt i want to suggest him to like my fan-page,its all on my website i dont want to put a landing page or something else on my fan-page.all of it is on my website,i don't want to put a landing page or anything else on my fan-page. Thanks


回答1:


there are only 2 ways for this:

-) use the edge.create event: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

downside: this can only check right after clicking a like button on your website. so, if the user comes back, you can´t be sure if the like button is still clicked. also, you never get the id of the user, of course (deprecated)

-) authorization with facebook login > you can check for the user likes > user_likes permission needed. but i doubt that you really want to authorize the user just for this...

the graph api call you could use:

me/likes?target_id=[page-id]

subscription: permission user_subscriptions needed. graph api call would be the following:

me/subscribedto?user=[user-id]



回答2:


You need user_likes permission to view like information about the current session user.

refer to: http://developers.facebook.com/docs/reference/login/user-friend-permissions/

then simply use fql to request information.

SELECT page_id FROM page_fan WHERE uid=me() AND page_id=22934684677

If user likes the page graph will return id of page. Example graph request like for page Facebook. http://developers.facebook.com/tools/explorer/135669679827333/?fql=SELECT%20page_id%20FROM%20page_fan%20WHERE%20uid%3Dme()%20AND%20page_id%3D20531316728

{
  "data": [
    {
      "page_id": 20531316728
    }
  ]
}

Else array will be empty.

{
  "data": [
  ]
}


来源:https://stackoverflow.com/questions/9299616/how-to-check-if-someone-is-liked-my-fanpage-from-my-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!