So, Facebook is supposed to be retiring FQL... today(8.8.16).
Is there a way to make Graph API requests, with something similar to WHERE ...?
For example, in FQL, this will bring me my status-posts who got more than 10 likes (and nicely order them from top to bottom)
SELECT message, like_info FROM status WHERE uid=me() AND
like_info.like_count>10 ORDER BY like_info.like_count DESC
How will you achieve this with the Graph API only? Is it possible at all?
No, there is no way with the Graph API to do that, you would have to get all posts and do the sorting/filtering on your own. You can filter by date though, with the since and until parameters.
Related
With FQL being phased out I need to achieve the same functions via the Graph API.
My application checks for new posts, comments and replies on a company page every X seconds.
I use 1 FQL to get new comments and replies by doing
SELECT post_id,time,fromid, text,id from comment WHERE time > (lastcheck) and post_id in (select post_id from stream where source_id = (PageID) limit 1000) order by time desc
This appears to work well ,I can add a comment to a 5 month old post and it picks it up.
How can the same be achieved with the Graph API?
I think that if what you have works then you do not need to change it. Contrary to what Facebook wants you to do (use the graph api), not every query can be translated to it. FQL is alive and kicking and used heavily both in the Facebook website and mobile apps.
I would like to find any of my own activity (post, comment, share, etc.) on another user's page or a fan page. That is, obtain a list of all the comments, posts and whatnot that I have made on user XYZ's page, or on SOMETVSHOW's page.
Is that possible at all? I've looked at the different relations that are accessible using the Graph API, but there seems to be no direct way to get this data.
One way to do this is to collect ALL of my own activity and then run this data through a filter that would extract just the comments, post, etc. that I left on a certain user's page or fan page. But that is not really efficient, especially if you have (like me) a very large amount of data to capture in the first place.
Also, I could go the other way and grab ALL of that user's or fan page's activity and the filter out my own posts and comments, but likewise, this would take an eternity and produce huge amounts of data that need to be processed.
Any ideas? Thank you!
You should be able to do this pretty easily via FQL:
SELECT post_id, type, message, created_time, attachment FROM stream
WHERE source_id = PAGE_ID AND actor_id = me() LIMIT 200
You will have the normal limitations of the stream table to deal with, so you may have to page back through these results to get everything you are looking for.
I want to get the most recent updates from my liked Facebook pages (graph.facebook.com/me/likes/). I thought I'd got it working using FQL with the below statement
SELECT source_id, share_count,likes, FROM stream WHERE source_id in (select target_id from connection where source_id=me() and target_type='page') LIMIT 100
However it seems that FB is filtering out a bunch of pages due to their various algorithms. Is there any straight forward way of getting around this? I'd just like to see all messages and decide whats relevant myself.
I was previously jumping onto every single page of my likes via the graph api, but obviously this gets a bit crazy if there are 700 odd likes in my profile.
Can anyone tell me if its possible to search public facebook streams for specific URLs? And if yes, what is the FQL and do I need to set access token?
Update: What about using graph api.... or even searching the link table? I tried using the graph api to search the stream table, but its not bring back great results.
You can search nearly anything in FQL using the undocumented CONTAINS() function:
SELECT actor_id, created_time, message, attachment FROM stream WHERE CONTAINS('stackoverflow.com`)
You need to be careful using it, because the results will be filtered after the query runs to only show items that are visible to the current session user. You may get empty data sets returned even though there are lots of items that meet your criteria. AFAIK, there is no visible_to_me field where you can filter the posts prior to the FB visibility filter.
You always need an access token to use the stream table.
I have an application where I want to show items that your friends have shared. This is basically a subset of data that would appear on your Facebook News Feed, so I am grabbing /me/home and then filtering out some things that I don't need.
The problem is that /me/home is extremely slow. I'm seeing a range of response times that is between 1200 and 10000 milliseconds with an average probably around 4 seconds.
Even with cached connections and a HTTP library that does SSL correctly these request times do not change much.
Does anyone know a better way to grab the News Feed? When I open Facebook in my browser, the News Feed appears pretty much immediately. So I am wondering if there is some Graph API call that is optimized for this data or has this result cached already.
Is there maybe an FQL alternative for this?
You can do this in FQL. This query should get you started:
SELECT post_id, actor_id, target_id, message, attachment FROM stream WHERE filter_key = 'others'
In the Graph API explorer on my feed, I get ~1000ms response times for the FQL query vs. ~2500ms for me/home.
For Facebook's home page, keep in mind that they use a series of AJAX queries to fill each of the boxes on your page a little at a time. I was on a very slow connection in a hotel last week and watched these fill box by box. The news feed fills first, five posts at a time, followed by the other boxes on the page. If page load performance could be an issue, you may want to move to an asynchronous model.
FQL will definitely help with that, as you'll be able to filter the data before it is returned by FB more finely than you can with just the Graph API.