如何使用 Graph API 抓取用户的 Facebook 提要?

How to scrape user's facebook feed using Graph API?

我想从 Facebook 抓取一些用户的帖子。帖子在浏览器中可见,当我登录并查看 http://fb.com/username URL. But when I'm trying to access the same feed using Graph API Explorer (https://graph.facebook.com/v2.3/username/feed) 我得到:

"error": {
    "message": "(#803) Cannot query users by their username (username)", 
    "type": "OAuthException", 
    "code": 803
}

如果我尝试使用 id 而不是用户名 (http://graph.facebook.com/v2.3/userid/feed),我会得到空 JSON 作为响应:

{
  "data": [
  ]
}

那么,有没有办法使用 Graph API 获取用户的提要?还是我必须模仿网络浏览器然后解析 HTML?

您不应该获取任何用户的提要,public 与否。您需要授权 user_posts 的用户访问他的 Feed - 并且仅限他的 Feed。

此外,Graph API 中不再提供用户名,您现在需要使用 App Scoped ID。当您授权用户时,您会得到它。

顺便说一句,根本不允许抓取:https://www.facebook.com/apps/site_scraping_tos_terms.php