Mohsin Shafique
Mohsin Shafique

Reputation: 935

FQL to search newsfeed

I am having a strange issue with an app that I am developing. I am using PHP SDK to call the Graph API on server side and here is my code that calls the API:

$params = array('q' => 'George', 'limit' => 100);

$newsfeed = $facebook->api('/me/home', 'GET', $params);

And next is the code to render HTML of the newsfeed. I have a footer below that once clicked, loads further posts. But what I have observed is that in case of searching the newsfeed by providing additional 'q' parameter, we do not get results beyond one week.

Now I am giving a second try to FQL instead of Graph API. Good thing with Graph API was that appending a q parameter to /me/home would do the searching for you automatically and you had nothing to do. But with FQL, this does not seems to be the case as per the following documentation suggests:

http://developers.facebook.com/docs/reference/fql/stream/

My idea is to use following FQL:

SELECT post_id, actor_id, target_id, message, comments, likes FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid = me() AND type = 'newsfeed') AND strpos(message, 'facebook') >= 0

Any ideas how the search can be implemented? I actually want to emulate the news feed within the application so please enlighten me about batching multiple FQL queries if you have any ideas on that.

Upvotes: 4

Views: 1232

Answers (1)

Luca S.
Luca S.

Reputation: 94

try to set the source_id = me() like this:

SELECT post_id, actor_id, target_id, message, comments, likes 
FROM stream 
WHERE source_id = me()
AND strpos(message, 'facebook') >= 0

Upvotes: 1

Related Questions