13

We have a web app where we need to track users "Likes" of URLs (not Facebook pages, external ones), because they earn credits for doing so.

To do this we're using JQuery and the subscribe (edge.create) event and it's working great. http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Unfortunately we can't seem to figure out a way handle the case where a user "Likes" a URL through our site, earns a credit, then goes to their Facebook Wall and "Unlikes" it, essentially cheating the system.

I played around with these two FQL queries. The 1st is supposed to return an object ID of a URL, and the 2nd should return the list of user_ids who "Like" the URL. But they seem inconsistent and don't always return data for every case I tested.

https://api.facebook.com/method/fql.query?query=select%20id%20from%20object_url%20where%20url=%22http://www.saschakimmel.com/2010/05/how-to-capture-clicks-on-the-facebook-like-button/%22

https://api.facebook.com/method/fql.query?query=SELECT%20user_id%20FROM%20like%20WHERE%20object_id=%22393958018726%22

We'd rather not have to get the users to authorize our app with Facebook, and give us permission to access their data, in order to make this work either.

Any ideas? Thanks in advance!

Kane
  • 899
  • 2
  • 15
  • 35
  • This thread has some good info but still doesn't resolve my problem: http://stackoverflow.com/questions/4876422/retrieve-facebook-users-that-like-a-url-web-page-via-open-graph – Kane Feb 22 '11 at 18:35

2 Answers2

4

In in insights table of FQL you have metrics "domain_fan_removes" , "page_fan_removes" , "application_like_removes" and "domain_like_removes" http://developers.facebook.com/docs/reference/fql/insights/ This might help.

https://api.facebook.com/method/fql.query?query=SELECT%20metric,value%20FROM%20insights%20WHERE%20object_id=118584441503782%20AND%20metric='page_fan_removes'%20AND%20end_time=end_time_date('2011-02-01')%20AND%20period=period('lifetime')&access_token=xxxxx

Balakrishnan
  • 1,073
  • 9
  • 9
  • Is there enough detail to support tracking individual users? The question mentions that a user Un-Likes and then Likes something again, and must receive credit accordingly. I'd like to see a code sample posted that can be run to determine if this info constitutes an answer for the author's requirements. – John K Feb 23 '11 at 15:46
  • A couple problems with this approach: (1) It doesn't work ;) Example: https://api.facebook.com/method/fql.query?query=SELECT%20metric,%20value%20FROM%20insights%20WHERE%20object_id=393958018726%20AND%20metric='domain_fan_removes'%20 and (2) It says "Insights are available for pages, applications, and domains with 30 or more connections." which won't work because our system has many domains with less than 30 connections. – Kane Feb 23 '11 at 19:45
  • query on insights need to have a time range, hence you received the error on the above query. Please try something like this https://api.facebook.com/method/fql.query?query=SELECT%20metric,value%20FROM%20insights%20WHERE%20object_id=118584441503782%20AND%20metric='page_fan_removes'%20AND%20end_time=end_time_date('2011-02-01')%20AND%20period=period('lifetime')&access_token=xxxxx The oauth access token provided should be on the user with the privilege "read_insights". – Balakrishnan Feb 24 '11 at 02:31
  • Doesn't this solution mean we'll have to get the users to authorize our app with Facebook? Or am I missing something? – Kane Mar 01 '11 at 06:13
2

With the JS Api you can use the FB.Event.subscribe,

FB.Event.subscribe('edge.create',
    function(response) {
        alert('You liked the URL: ' + response);
    }
);

or you can use edge.remove if user unlike a url:

FB.Event.subscribe('edge.remove',
    function(response) {
        alert('You unliked the URL: ' + response);
    }
);

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Philip
  • 5,011
  • 2
  • 30
  • 36