简体   繁体   中英

FQL search public posts

I'm trying to do a search using FQL. Using the Graph API, it works but there are more options using FQL. Using something like

https://graph.facebook.com/search?q=myquery&access_token=mytoken

it work fine.

I'm looking for the equivalent in FQL.

What query I must write in here

https://api.facebook.com/method/fql.query?query=SELECT%20post_id%2C%20actor_id%2C%20target_id%2C%20message%20FROM%20stream&access_token=mytoken

The query above give me that

Parser error: unexpected end of query

I want to search in all public posts. I've been looking everywhere but I did not found any solution.

Thanks.

For searching public posts for a string, you need to use the Graph API, and then filter those posts in your script. I don't think searching all public posts is possible in FQL. While FQL is more powerful, it is also more limited.

You are getting an error because you don't have a "WHERE" clause in your query. This is required in FQL.

The limit comes in because you must use at least one indexed column in your WHERE query. For the stream table you must specify either a post via post_id , a user via source_id or filter_key , or a live stream via xid . The indexed fields are marked with a * on the documentation site.

For instance, [this FQL][1]

SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others' 
   AND strpos(message, 'the') >= 0

will get you all posts that show on your access token owner's wall that have not been posted by the owner, with the string 'the' in them. That is the best you can get. If the post isn't visible on their wall, then you won't get the post.

If you try to leave out an indexed field, FQL will throw a 'Your statement is not indexable' error.

[1]: SELECT post_id,actor_id,target_id,message FROM stream WHERE filter_key = 'others' and strpos(message,'the') >=0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM