Facebook Graph Query Search Stream for Link - facebook-graph-api

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.

Related

"WHERE clause" in Facebook Graph API

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.

FQL gives empty data from stream table for multiple source_id, but works properly for the Graph Api Explorer

I have been trying to run some FQL query from an app I have set up. The FQL is supposed to get last few posts from a list of pages using "source_id IN ()" clause. It works from the Graph Api Explorer (gives an array of post data), but fails for my app (gives an empty array). I have got access_token with read_stream permission in both cases.
This happens only for multiple pages. If I give just one page using "source_id = " clause, I get list of posts in both cases. I don't want to use multiple queries each containing a single page id, as the page list would be long and I need only a few pages.
Here is the FQL I am using in both cases :
SELECT post_id, message, place, updated_time, actor_id, like_info.like_count, share_info.share_count, comment_info.comment_count FROM stream WHERE source_id IN (331288023558058,186202548075080) AND actor_id = source_id LIMIT 0, 10
Is there anything I need to do in order to make this query work for my app?

FQL: group results that have a field in common

I'm developing an application based on the facebook checkins.
I'm searching a way to group the results, that I receive asking for an user's checkins, by the page_id with a single FQL query.
Generally I would try with the GROUP clause of the SQL language but i read that this clause isn't supported by FQL.
Thanks in advance,
Luca
Since there is no GROUP BY available, as you said, this is not possible via a single FQL query.
Your options are to either do that yourself while processing the data you received by looping over it and transfering it into the desired data structure, or if you know what pages are involved beforehand, by doing a multi query including one single query for every page_id.

How to access my user activity on other users' pages or fan pages using the Graph API?

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.

Is the stream table from the REST API incomplete?

I'm trying to get all my wall information (status, photo tags, friends' posts, etc.) with the stream table.
But when I try to do that, a lot of information which is on my wall doesn't appear in the stream response.
For example, I can't get my December status.
Can someone help me?
From my experience, the stream table is incomplete. Using FQL to query the full table results in missing entries. A workaround is to query to original tables of the entries, e.g. the status table:
SELECT uid, status_id, time, source, message FROM status WHERE uid = me()
This is more complete. Obviously, you would have to query the photo table and others in parallel. In order to not loose too much time, you can batch the queries.
The stream table, however, seems to be fine for posts originating from friends.
A downside - apart from the multiple queries - is that the other tables don't have additional meta information about likes or comments, so these need to be retrieved in a second step then.