user3163213
user3163213

Reputation: 701

get user like of link using facebook api

I am trying to get user's like from a given link-

for example my link would be- "http//:www.example.org"

Now trying to get whether user has liked this link before or not.

            FB.api({
                    method: 'fql.query',
                    query: "SELECT uid from object_id WHERE uid = " + user_id + "and link_id =" + page_url
                  }, function (rows) {
                    console.log(rows);
                  });

But this query doesn't shows undefined in console.

I want to know the way of doing this using facebook graph API reference.

Upvotes: 0

Views: 296

Answers (1)

andyrandy
andyrandy

Reputation: 74004

Afaik you can only get Likes of Facebook Pages via the Facebook API, but not Likes of external websites. Also, keep in mind that FQL is deprecated and only available in v2.0 of the Facebook API. Which means, it will get removed when support for v2.0 runs out (2-3 years probably).

Getting the Facebook Page Likes is pretty easy though: /me/likes ... Although, you need to let Facebook review the permission in v2.0.

Upgrade guide (v1.0 > v2.0): https://developers.facebook.com/docs/apps/upgrading/

There is one way to check if a user liked something on an external website, but only right when he clicks on the Like Button: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.0

Edit: After some testing, i figured out that it is indeed possible to get the Likes. Although, i think there is a bug in FQL - You can get a list of external Likes with the following FQL query:

SELECT url, user_id FROM url_like WHERE user_id = me()

...but if you add the url to the query, the result is emtpy:

SELECT url, user_id FROM url_like WHERE user_id = me() AND url = '...'

There is a similar question on stackoverflow btw, maybe you want to take a look at the answers: Retrieve Facebook users that like a URL / web page via Open Graph

Upvotes: 1

Related Questions