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

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.

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.

How to get all user's likes using facebook's graph API

How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.

Filter by post author using Facebook Graph API

Here's the problem I'm having -- I want to pull the latest 20 wall posts from a company's Facebook page using Graph API, but only those posts that were authored by that company. For instance, if I were pulling from the Grey Poupon Facebook page, I don't want any of the wall posts that their fans put up, just the ones that Grey Poupon put up.
From my vantage point, there's no way to do this, other than by pulling way too many, then cycling through each result and checking the "from" data to make sure it matches the page name till that limit hits 20. But that's awfully inefficient and still doesn't guarantee a result set of 20. Am I missing something, or is that my only option?
What exactly are you requesting from the API – /pageid/feed, or /pageid/posts …?
The latter should only contain the page’s own posts.
Also, you could use the FQL stream table to filter by actor_id.

Comments not crawlable by search engines?

I was wondering if Search Engine spiders can see the comments, when I open the source of the page the comments are not showing up (same as with disqus), so I'm assuming when the search engines crawl the page they won't see the comments either? Is this assumption correct? If so, is there a way to change this?
Found the solution:
http://developers.facebook.com/docs/reference/plugins/comments/
How can I get an SEO boost from the comments left on my site?
The Facebook comments box is rendered in an iframe on your page, and
most search engines will not crawl content within an iframe. However,
you can access all the comments left on your site via the graph API as
described above. Simply grab the comments from the API and render them
in the body of your page behind the comments box. We recommend you
cache the results, as pulling the comments from the graph API on each
page load could slow down the rendering time of the page.
Only what get thrown to a crawl engine the crawl engine can see, hence these comments should be outputted in able to get crawled and saved into the SE database or whatever it uses to collect data about websites, you might check the headers the connection request came from, if it belongs to a crawl engine and that's called a user agent in our case humans (browsers), here you can find a way to detect crawlers using PHP, after detecting it you force the comments to be shown in order to get crawled, here also a good resource on how to deal with crawlers from Google itself.
Now if you're talking about Facebook comments, it's impossible to let them indexed by the crawler or SE, when a crawler attempt to visit one of the Facebook pages it won't be able to see users' data because of the login page, and if you are talking about Facebook plugins you may do what what I suggested above, article talking about Facebook comments crawling.

Show tagged images from facebook on website?

I am trying to achieve similar functionality to the one shown here...http://blackmilkclothing.com/collections/leggings/products/circuit-board-grey-leggings
there fan page https://www.facebook.com/blackmilkclothing allows people to hash tag a photo and then populate it on their website like the link above.
Loading a series of tagged images from my facebook fan page to my website. I am not positive how this is acheived? I am assuming some kind of api process but any help in the right direction would be appreciated.
Thanks! All help is appreciated
See the 'tagged' connection of a Page in the Graph API: https://developers.facebook.com/docs/reference/api/page/
It returns a list of objects the page is tagged in, including photos
If you need background knowledge I suggest these links in particular:
Graph API overview: https://developers.facebook.com/docs/reference/api/
Page login: https://developers.facebook.com/docs/authentication/pages/
After a good bit of trial and error I've found the most efficient way to query photos tagged to a particular Facebook page is to use Facebook's FQL interface to retrieve a list of stream posts.
With FQL you can limit the queried objects to only those posts containing images (unlike with the higher-level Graph API calls which will return all posts, many of which may not have associated photos), and you'll also have more granular control over composition of the result set.
Keep in mind that Facebook doesn't have true hashtag support (only Facebook pages can be tagged), so to simulate the hashtag support that Black Milk Clothing encourages, you'll need to parse and filter the photo message text yourself.
As an alternative quick and easy solution, I've rolled the results of my efforts into a free online service called TagTray -- with TagTray I've added an interface for building and curating hashtag based galleries from Facebook, Instagram, and TwitPic (including application-level Facebook hashtag filtering) that can be framelessly embedded into a site with a few lines of JavaScript.