Reputation: 23
I am using a like button for my web site, got it from the facebook page using the iframe version. I want to show the number of people like my site only when this number is bigger that 50. I was thinking that I could use an fql.query for getting the like_count and if this is bigger that 50 then show it. I don't want to create a Facebook App in the developers page so I don't have an App id etc. What I have done is:
$data = array(
'method' => 'fql.query',
'query' => 'select like_count from link_stat where url="http://www.mysite.com',
'callback' => ''
);
But I do not know how to store the results in a PHP variable and if at the end I can display them only when I want to.
I have searched a lot about it and not find something yet so I would appreciate a lot if someone could help me.
Upvotes: 1
Views: 2460
Reputation: 1627
You can do a request to http://graph.facebook.com/http://www.mysite.com/ in Javascript, and it will return a JSON object with the number of shares and comments thus:
{
"id": "http://www.mysite.com/",
"shares": 70503,
"comments": 1
}
That shares number should match the number you will get in the like button.
Upvotes: 2
Reputation: 3201
Actually, I don't know if you do need to register an App. I know you can do some things using the Graph API without an App ID (although obviously if it's a closed group or event I'm guessing you'd need to be able to get an OAuth access_token for that). I haven't used FQL at all, but I'm pretty sure that you don't need an App ID to do some things.
In answer to the OP, this link: http://developers.facebook.com/docs/reference/fql/link_stat uses the $facebook object that they seem to use throughout. Take a look at this code on github: https://github.com/facebook/php-sdk/blob/master/examples/example.php
That might help.
Upvotes: 0