Fan-gate, like-gate, show-to-connections, with javascript and how is the box?

I have a similar facebook on my website (not an iframe application) where I need to create private content. I understand that FB.Event.subscribe uses edge.create and edge.remove, but I really need to know if the user likes this page more than just if they become fans or cease to be fans. Is there anything I can see as a callback, possibly from xfbml.render?

I am limited (by my company) to using interface languages, which means javascript is really my only option at the moment. I would gladly use the "signed_request" parameter, but I can best say that it is available only through server languages.

Is there a way to determine if someone already β€œlikes” a page using only javascript?

+4
source share
2 answers

Yes, you can do it completely in javascript using the FB Javascript sdk.

function RunLikeCheck() { var likeId = 'yourLikeIdHere'; FB.api({ method: 'fql.query', query: 'SELECT uid FROM page_fan WHERE page_id = ' + likeId + ' AND uid = me()' }, function (response) { if (response.length == 1) { $("#HasLiked").val('true'); $('#frmAllow').submit(); } else { $("#HasLiked").val('false'); $('#frmAllow').submit(); } } ); } 

Now it is assumed that you are already logged in and have the correct permissions.

+6
source

Here is another example of javascript code for implementing a similar gateway that does not require calling FB.api (but requires reuse by the user each time the page is visited).

http://linksy.me/viral-gate

0
source

Source: https://habr.com/ru/post/1344114/


All Articles