Searching Facebook all public posts only for posts

2019-08-23 03:53发布

Is it possible to search Facebook all public posts only for posts with links using the Graph API or FQL?

I tried a bit with https://graph.facebook.com/search?q=watermelon&type=post but couldn't figure it out...

1条回答
狗以群分
2楼-- · 2019-08-23 04:12

This query comes close:

https://graph.facebook.com/search?q=http:&type=post&fields=link

the "q" param says "only return posts whose message contains the string 'http:'", which gives a good first cut, but still lets some through without real links. You can then walk through the response and throw away any results that don't contain a 'link' field. If all you care about is the link itself, then "fields=link" says "only return the id, created_at, and link fields," and makes the query go a bit faster.

Looking it over, it appears that certain URLs do not turn into links -- e.g. bit.ly URLs. So maybe you want to get the message and parse it yourself, e.g.

https://graph.facebook.com/search?q=http:&type=post&fields=link,message

You may also want to do a search on 'https:' to get those URLs as well.

查看更多
登录 后发表回答