facebook graph api determine if user likes url

后端 未结 6 1292
-上瘾入骨i
-上瘾入骨i 2021-02-09 17:20

I want to display a different message if a user is currently logged in to facebook and likes the current page. I understand:

FB.Event.subscribe(\'edge.create\'         


        
6条回答
  •  情深已故
    2021-02-09 18:04

    I'm pretty sure you cant do what you want (in this context).

    Take a look at this page : http://fbrell.com/fb.api/does-like

    You'll see you need the user to approve a permission to view the likes.

    It's a huge security risk to allow someone to see the 'likes' of a user - even for the current page. Think about it you can easily spoof the current page and pretend to be any page.

    BUT...

    What I recommend you do is just set a cookie for your own benefit (in javascript) when the user 'Likes' your page. Assuming you're getting a large percentage of your 'Likes' from this page then you can safely correlate the presence of the cookie with a 'Like'.

    I've seen some security exceptions doing this, but it seems to work (at least in Chrome).

提交回复
热议问题