How to get how many times specific object was liked?
Answer: http://developers.facebook.com/docs/reference/fql/link_stat
and
How to get the most liked links in my application?
UPD 3: another question then: how to get the object_id for given liked page
Answer: object_url fql table
You can use a SQL (FQL) query and then count the users who liked the object. Heres information on the query: http://developers.facebook.com/docs/reference/fql/like
Related
I have FB post
I can click "77 people like this" and get all people I needed.
Question: is there way to get these people by FB API ?
PS I want to get 3 random names from these list so I need to have these people in JSON format
It's easy to do with FQL. This gets you three random ids of people who liked this event
SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3
If you wanted to get their names instead, you'd rewrite the query like this:
SELECT uid, name, username FROM user WHERE uid IN
(SELECT user_id FROM like WHERE object_id = 336638873112346 ORDER BY rand() LIMIT 3)
I'm one of the co-founders of Kither, a platform for checking all of your Facebook stats. We have added many features which requires to fetch all of our user's posts likes.
As of August 6, 2016, FQL is deprecated.
Facebook's Graph API's still available and you can call https://graph.facebook.com/{api-version}/{post-id}/likes to get likes on posts. But remember, Facebook uses pagination on likes if there are more than 1,000 of them.
Now, In this case you'll need to call the next page url.
You'll need to call the next url unless you've got all the likes. (you won't find any next field if there are no more likes)
To get how many people have liked that post (i.e. count), you don't need to page through results. You can simply use https://graph.facebook.com/{api-version}/{post-id}/likes?summary=true and you'll get an extra field containing all likes' summary, including their count.
Same can be done with comments and recently added, reactions.
I am trying to retrive posts from a users news feed in which my fan page has been tagged. I'm seaching through stream_tag with FQL but zero results are returned.
Posted a comment on my wall in which I tagged a friend, myself, and my fan page.
Used the Graph API Explorer - developers.facebook.com/tools/explorer/
Used the explorer as one of my apps, and granted every type of permission.
Did the following query:
https://graph.facebook.com/fql?q=SELECT post_id,actor_id FROM stream_tag WHERE target_id = [fan page id]
The following is returned: data: []
This seems to indicate that there is no resaults but I know the tag exists. When I do a query with target_id=me() results are returned, but according to the documentation the target_id can also be a fan page( http://developers.facebook.com/docs/reference/fql/stream_tag/ to craft the query).
How can I create a query that returns posts my fan page is tagged in?
I was trying to do the exact same thing when I came across your post. It looks like there currently is a bug report open that the stream_tag table does not work with when the target is a page.
I'm using https://graph.facebook.com/search?q=watermelon&type=post to retrieve posts with query watermelon. Is it possible to also get the like count for the posts I retrieve?
The likes element is returned for search result entries that have been liked. Not all posts have been liked or the users permissions don't allow viewing of likes. Here is a screenshot from the graph explorer though for your query which has some likes information:
The Facebook FQL does not have the feature of count, but you could always count the number of objects in the array with whatever language you are using.
Can anyone suggest how to track the comments and other objects (videos,photos,etc) which a user likes in facebook? Assuming that the user has registerd to my application.
You can use FQL with the like table.
http://developers.facebook.com/docs/reference/fql/like/
Reference includes examples.
But you can't get a list pf everything the user likes. If you know what object you want to track you can also use the link_stat table:
http://developers.facebook.com/docs/reference/fql/link_stat/
Using the Facebook API with the FQL language, how can I get a list of the users that liked a given URL? I got the URL and want to query Facebook to see how many people and what users liked that URL.
Using PHP or ASP.Net... doesn't matter, just want to know how to write the FQL query.
Sadly this data isn't available. What's possible via the Link Graph API objects and the link FQL table is just retrieving a given instance in which a link was shared by a user. You can get the count of likes on a user's posting of a link, but this likely isn't what you want.
Discussed this 3-6 months ago with guys at Facebook, and the consensus then was also that getting this data via API is impossible. As far as I know things haven't changed, and there are some privacy arguments for keeping this data out of the API.
'SELECT user_id FROM like WHERE object_id IN (SELECT link_id from link WHERE url = 'YOUR URL HERE' AND owner = 'YOUR USER ID HERE' '
Like FQL Table
Link FQL table
In order to access user's likes, the application needs to have user_likes permission from the user. After that if you access http://graph.facebook.com/me/likes with appropriate access tokens, all the object IDs (including external websites), the current user has liked will be listed.
(this is in reply to bounty question, which seems a bit different from the original question asked on this page)
It's not using FQL but...you can see the most recent 500 users that have like your page by going to: https://www.facebook.com/browse/?type=page_fans&page_id={id} but you would have to scrape this to get the information and it won't work for more people besides the most recent 500. Here's the gotcha, you've gotta be an admin of the page_id to see it.
You can only get the fans of pages that you are an administrator for. So you have to provide an access token with your request associated with an admin account of the page you are trying to get the fans.
Facebook's FQL documentation here: https://developers.facebook.com/docs/reference/fql/page/ tells you how to do it. Run the example SELECT name, fan_count FROM page WHERE page_id = 19292868552 and replace the page_id number with your page's id number and it will return the page name and the fan count.