Query for pages of a specific type on Facebook - 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.

Related

How can I get a list of all "likable" Facebook pages?

I'm exploring the Facebook API for the first time - partially to research a web app idea I have and partially out of pure curiosity. The Explorer tool has been a great help with most things.
I'm trying to get a complete list of "Likable" pages on Facebook such as: Movies, Music, Books, TV Shows, etc. I understand how to get a list of pages that a user has liked, but I want the entire index of pages that exist.
All of the strings I've worked with so far start with /username. Is there another prefix for querying Facebook in general?
No, this is not possible and doesn't exist in the API.
A query like this is way too resource intensive.
You can use the
/search?q={query}&type=page&access_token={app_access_token}
with {query} as the search string, {app_access_token} as your App Access Token, as outlined at
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
It's not possible to retrieve or search for whole Page Categories.

Final Checklist/Written Approval for Facebook Graph Use

i am using this endpoint
https://api.facebook.com/method/links.getStats?urls=
to collect the number of likes of specific urls. I want to display this information on a front end but do not want to make unnecessary API calls (there are over 25,000 posts). I would like to retrieve this information and store it so it can be retrieved from our database. On some pages, there will be over 10 of these accessible view a hover effect from a mouse. I would prefer to not have to load the page up with javascript targeted elements everywhere. It would be much easier to have the information stored and updated periodically. We will not be going over the impression limit or even coming close, but I would like to just make sure I'm not doing anything that will get me in trouble.
I would like permission to utilize this data to help increase pathways between our site and Facebook to allow people to share the page. I'm pretty sure we're doing everything correct but would just like to make sure and not step on anyone's toes.
I read through the checklist here
https://developers.facebook.com/docs/opengraph/submission-process/
however I don't know if what I'm doing would be considered an app....? Any advice would be appreciated.
Have a look at my answer here: How do I get the likes number from facebook for a given url?
You can also use FQL queries with IN lists to query multiple URLs at once. Please consider that a FQL statement can have a maximum length of 2048 characters.
select url, like_count from link_stat where url in ('URL1', 'URL2', ...)
The "cheklist" you linked is completely unneccessary, because you don't need to submit anything related to OpenGraph objects or actions. You can even use the functionality without using an Access Token, because the link_stat table is public (https://developers.facebook.com/docs/reference/fql/link_stat/)

"Top Posts" depending on facebook likes

I have an idea to create a "top posts" feature to my website, which creates the "top" list depending on how many likes and shares that a post have on facebook.
Users may see how many likes an post has received so far since they only have to ask for a single, defined url. However, the website itself has to be able to query all the links that are tied to itself (which have a predefined url template like website.com/[post-id]) to create the "top" list. Is it possible to do something similar (or achieve the same result in a different way)?
Any ideas on a real workflow about something like this will be appreciated!
this seems like a little but interesting project. I don't know if there is a feature that could get that directly in the way you want, but i did something similar.
First you have the Graph API, with that you can get the Posts of a user using feed, with that every post is telling you how many likes does it have which you can get with POST_ID/likes.
Then you'll have to check for changes in the post periodically comparing its created_time and updated_time.
This could seem very hard, because you have a lot of posts and you have to check them all for updates, but you can use batch_requests so you can check them all at once.
I have made a bookmarklet which shows top posts in the Facebook News Feed as well as Google+, Twitter and Instagram Profiles.
Just add a new bookmark in your bookmarks bar and replace its URL with the following code and save it, then go to the social network website and run it:
javascript:(function(){var s=document.createElement('script');s.src='https://niutech.github.io/topnewsfeed/topnewsfeed.min.js';document.body.appendChild(s);})()
The source code is available on GitHub.

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.

Get top x "likes" using Facebook API

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.