How to get category specific likes for a facebook user using graph API - facebook

I'm pretty new at this. I was playing with the Facebook Graph API and was able to pull all my LIKES using the call
$all_likes = json_decode(file_get_contents('https://graph.facebook.com/me/likes?access_token='.[access_token]));
Now when I display these, they have a field called category which has different values like TV Show, Book, Public Figure etc.
So my question is how do I get category specific likes - for instance I just want to fetch ALL the BOOKS that I LIKE
Obviously its possible to fetch all the likes and store them on the server side and work on it but the LIKES list is too huge for certain users and it doesn't make sense to pull everything if you just want to show a certain category.
I feel like I'm missing something.
If its not possible through the graph API call, then even a FQL solution is welcome.
Thanks for your time
R

You can use FQL, just like in this answer:
SELECT page_id FROM page_fan WHERE uid=me() AND type="MOVIE"

Related

facebook likes that WE have done

We have several people working on our Facebook page, and I am trying to find out if there is a way to list all the companies that WE have liked - not the ones that like us.
I know that isn't possible to do (apart from analytic data). We are a chamber of commerce, and we were liking all our members who are on Facebook, hoping to be able to look back and find out how many are actually on Facebook.
Hope this makes sense, and I hope it is possible. :)
Sure just go to: https://developers.facebook.com/tools/explorer (you must be a registered facebook developer to acces this tool).
Then on the input where you have this:
your_fb_id?fields=id,name
change it to this
your_fb_id?fields=id,name,accounts and press send.
You'll get all the pages wich you're administrator, choose the one you want by clicking on the respective ID. Now you're querying the page you've chosen. Last step, on the input to make queries change it to this:
your_page_id?fields=likes
EDIT
The previous request only returned the number of total likes made by the page.
To get the likes made by the page on other pages you have to use FQL Query
Change from Graph API to FQL Query and paste this
SELECT page_id, name FROM page WHERE page_id IN (SELECT page_id FROM page_fan WHERE uid = your_PAGE_ID)
This is without doing any code, if you want to get the information and format it on your own way, you'll have to develop an app where you grant the permission manage_pages and user_likes(this one I don't think is mandatory though), use the graph api to get the likes and format the json returned data

How to get all people who liked Facebook post?

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.

How to get the facebook user id that likes my website (not a facebook site)

I am making a raffle within the people that had make an "I like" to a certain article of my external website (non facebook). In order to choose the winner I need to know who has made the I like.
This query:
https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url='myWEBSITE'&format=json
Only get me the total count of I Likes but not the users ID
This query is perfect:
https://api.facebook.com/method/fql.query?query=SELECT%20user_id%20FROM%20like%20WHERE%20object_id%3D%MY_object_ID&access_token=MY_ACCESS_TOKEN
But how do I get an OBJECTID for an external url??
Thanks in advance
Object can be any thing like video, note, link, photo, or album but can not be any FB page or Url.. So I guess its not possible to get the user Id for a URL.
If you are using JS SDK / Like plugin in your website to like it, i think you can subscribe to an event and then use some ajax calls to get those userIds whenever they instantly like it.
See Somnath Muluk's answer in https://stackoverflow.com/a/13467793/269521

How do I get a list of friends who clicked "Like" on an external page?

PART A -
There are many many questions like this, but none of them seem to provide a working solution. I want to get a list of friends who clicked the Facebook "Like" button on an external site.
NOTE: This is NOT for a Facebook page. In this case, I know I can query the page_fan table.
To get the list of Facebook page-likes for example, I can use the url_like table. I guess I just want a way to invert this table. I know I cannot get a list of ALL people that liked a link due to privacy concerns, but I want a list of my friends alone - which should be fine.
I know facebook does this internally every time I see a Facebook Like button... right below that there is statistics about my friends that also like the same link. How do I get this using FQL?
PART B
Equivalently, how do I get a list of friends that shared a specific URL as a link? I cannot search the link table by url because that is not indexed. Also, the link_id is not the same as the Open Graph ID of the URL.
I tried select link_id from link where url="http://urladdress.com/a/b.html" and owner in (select uid2 from friend where uid1=me()) but that neither throws an error not returns anything... just stalls.
Part A: you can't.
Part B: you can't the way you are trying. You might be able to get the feed for every one of the users friends and look for that url from their feed, but it will be painfully slow.
Lots of people would like to know this but Facebook is (rightfully so) not giving this information out. That is why you see lots of questions regarding it but no working solutions.
You could possibly look into the read_insights permission. You might not be able to get the exact information about "likes" (yet)... but you will be able to get other possibly useful information.

Ways to query Facebook Graph "do I like x?"

I'm setting up my app to basically do what the FBML 'like' button does: like, unlike and show like count, for objects from the user's "me/home" stream.
I have no problem doing any of the above functions, but I'm having a very tough time getting the api to tell me if the user likes the thing already (so I can set the button to 'unlike'). The graph api is telling me I'm not allowed to search user's likes. Is there an FQL solution?
Thanks
There is like table where you can check through FQL if someone likes something.