Get top x "likes" using Facebook API - facebook

Is there a way to get the top likes of a particular section of a site? For example, I want to get all top x likes of example.com/directory. I'm not particular about which method (Graph, FQL, etc), I just want to find the best method.

We currently do not support prefix queries for URLs or sorting by number of likes. If you have the set of URLs, you can use FQL and the http://developers.facebook.com/docs/reference/fql/link_stat table to get the stats for each of them.

Related

Query for pages of a specific type on Facebook

I need to have something like http://fanpagelist.com/category/musicians/ in my web app.
Basically I need to allow users to search through Facebook pages of musician/band category and sort by number of fans.
The closest I got was with this FB Graph API call:
search?q=musician&type=page&limit=25&after=MjQZD&fields=name,fan_count,category
But that is searching for pages that have 'musician' in the name, not in the category field.
Any idea? It must be possible since fanpagelist can do it...
There is no way to filter the results from that search endpoint directly.
You are limited to the options described under https://developers.facebook.com/docs/graph-api/using-graph-api/#search, and that basically means you can search by name, but nothing else.
So you will need to filter the results on your end.

Get all latest entries in users news feed

Does anyone know of a way to retrieve the users entire news feed? Querying /me/home does filter some stories from. Also, it seems to retrieve the top stories. Is there any way to retrieve the latest stories?
It doesn't matter whether it's through the Graph API or FQL.
me/home is pulling posts in order of created date on my end
https://developers.facebook.com/tools/explorer/135669679827333/?method=GET&path=me%3Ffields%3Dhome.limit(20).fields(created_time%2Cupdated_time%2Cid)
try this as your query, you can mod fields to include any you need.
me?fields=home.limit(20).fields(created_time,updated_time,id)
if it is still out of order because of your cookie settings from the actual home feed, you can force it to reorder by passing the array in sort(); "php".
for sort() refer to: http://php.net/manual/en/function.sort.php

what is the limit for the # of returned objects in graph.facebook.com/me/likes?

I need to get ALL user likes at once without pagination.
I could hit: graph.facebook.com/me/likes ...however, is there a limit to the # of objects returned by facebook? if so, what is that limit and can it be overwritten?
The default limit is something like 25 results. You can specify a limit by providing a limit parameter to facebook:
https://graph.facebook.com/me/likes?limit=100
Checkout the API Documentation under the heading "Paging".
That said, there's never a guarantee that you'll get all the likes at once, even if you set the limit parameter to be greater than or equal to the number of likes on an object.
On top of that, you'll often find that the number of likes reported on the Facebook website or by the Graph API is higher than what you can get by fetching the /likes connection in the Graph API. I'm trying (and failing) to find the SO question that talked about why that is, but if I remember right that number sometimes includes shares and other actions, not just likes.
You should use the pagination to page thru all the data that the Graph API can return.

Any way to query either ALL Facebook Pages or the TOP 20% (by likes) using Graph API or FQL?

I want to build my own list of the most 'liked' pages on Facebook. FB itself appears to do a version of this, at least for each letter of the alphabet. Each directory page, such as http://www.facebook.com/directory/pages/A lists the top 20 most liked pages starting with that letter.
If I knew the IDs of every FB page then I could easily grab its like count using the graph API, but I don't know of a way to get that initial list. I'm sure it's huge, and honestly, I really would rather just have the top 20% or so of all pages. But if I had them all I could do the sorting myself.
I've searched the FB dev forums and looked through their docs but can't find a way. Queries using FQL don't appear to take wildcards either.
In FQL, you can search the page table by name. This doesn't allow wildcard searches though. Using the graph api, you can perform page searches using this url:
https://graph.facebook.com/search?type=page&q=test (You would want to future proof this by adding an access_token parameter to the end). A third option would by to use search engines to search for Facebook pages. Finally, you could scrape and parse the Facebook page browser by using this url.

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

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"