If I put a facebook like button on a webpage, can I use FQL to query the number of users that 'liked' the page?
Yep. Try the following FQL:
SELECT like_count FROM link_stat WHERE url="http://your-web-page-url";
There's more stats available from the link_stat table as well. The table reference is here.
Related
I want to find which photo, video, status or other objects I liked in facebook.
Earlier I used fql to search in the like table:
SELECT object_id FROM like WHERE user_id=me() LIMIT 5000
But, in facebook api 2.1, fql is no more supported, so I need to use graph api to replace the above fql.
So, how can I use graph api to get my likes in facebook?
And I need to find who posted those objects also. In fql I used:
SELECT uid FROM status WHERE status_id IN (SELECT object_id FROM like WHERE user_id=me() LIMIT 5000) ORDER BY uid LIMIT 5000
I nee Graph api for the above fql also.
Plese help!
Just call the endpoint "<userid>/likes". This will give you the information. You need the proper permission for it though: "user_likes".
I'm syncing Facebook comments to a database and showing the Facebook comment box on a webpage. There are some inconsistencies with what is synced and what is shown in the Facebook comments box.
First I'm getting the comments with an FQL query. The FQL is as follows:
SELECT post_fbid, fromid, object_id, text, time FROM comment WHERE object_id in
(SELECT comments_fbid FROM link_stat WHERE url = 'http://www.storaensometsa.fi/metsa-ja-mina/')
If you run the query in Facebook Graph API Explorer it returns two comments.
Now, if I add a Facebook comment box to the page above (http://www.storaensometsa.fi/metsa-ja-mina/) it shows zero comments (scroll down the page to see the comment box).
Any thoughts why this is happening? Shouldn't there be two comments in the comment box also? Is the FQL query somehow incorrect?
Why really is FQL necessary? You have to write such a complex query to get the comments, where you can easily get them using the Graph API /comments. Here's the API call:
/comments?id={url}
So to get the comments from your url, simply \GET:
http://graph.facebook.com/comments?id=http://www.storaensometsa.fi/metsa-ja-mina/
(you can check the result in the browser)
When I use https://developers.facebook.com/docs/reference/fql/link_stat
i got this informations like_count, commentsbox_count , share_count , comments_fbid
like_count is the number of times Facebook users have "Liked" the page, or liked any comments or re-shares of this page. can I only get the count of users who clicked on my like button page ?
You are already getting the like count, just make your fql as below
SELECT like_count FROM link_stat WHERE url=your_url
I need to get page notifications(new comments, new likes, new post likes etc.). Is there any solution that I can make it realtime?
Realtime api doesn't support it.
FQL doesn't support it.
Realtime API does not support it, however FQL does support it. Given a URL, you can always get comments and likes using comment and link_stat tables.
http://developers.facebook.com/docs/reference/fql/comment/
SELECT post_fbid, fromid, object_id, text, time
FROM comment
WHERE object_id IN (
SELECT comments_fbid
FROM link_stat
WHERE url ='http://developers.facebook.com/docs/reference/fql/comment/')
link_stat table has comment_count, like_count etc as well. You have poll for this content, as you will not get realtime notifications.
How can I retrieve the list of Facebook users that have clicked the like button on an external site?
Say I have a like button:
<fb:like href="http://example.com/xyz"></fb:like>
I'd like a list of FB user IDs of people who have liked it.
I've tried OpenGraph:
https://graph.facebook.com/OBJECTID/likes/
(where OBJECTID is the id of the like example.com/xyz)
and FQL
select user_id from like where object_id in (
select id from object_url where url = 'http://example.com/xyz'))
but both return empty results.
I can see from other calls that the likes are counted alright, but I can't get the actual users.
Anyone know what permissions etc. I'd need to retrieve these?
Also see this question for sample code.
The simple answer is 'Its not possible to get individual user ids who liked a page'.
https://graph.facebook.com/cocacola/likes?access_token='xxxxxxxxxxxxxxxxxxxxxxx'
will surely return the data about the likes from the user/page but not the list of users who liked the specific object(in this case coca-cola). But make sure you send a proper access_token with proper permissions.
The FQL like is used to get the likes of any objects like video, note, link, photo, or album. To get liked users count of a page please use either link_stat or page from FQL.
the sample query will be like
SELECT url, normalized_url, share_count, like_count, comment_count, total_count,
commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url="facebook.com"
SELECT name, fan_count FROM page WHERE page_id = 19292868552
For more clear answers on this, please read the answer by Jonathan Dean in How to list facebook users who like a page or interest
or ifaour answer in Querying Users who 'like' my Facebook Page