简体   繁体   English

使用Facebook Graph API获取新闻提要

[英]Get news feed using Facebook Graph API

I am using the following to make my requests to Facebook 我正在使用以下内容向Facebook发出请求

$facebook->api('/feed', 
array(
  'access_token' => $_SESSION['fb_access_token'],
));

However, I want to get the news feed of the user. 但是,我想获取用户的新闻提要。

Not to be confused: I do not want the feed of a certain user, much less of a given page. 不要混淆:我不希望某个用户的feed,更不用说给定页面的feed。

I want the News Feed/Feed Stream the user views when accessing Facebook, one that contains the posts of your friends, etc. 我希望新闻订阅源/订阅源在访问Facebook时流化用户视图,其中包含您朋友的帖子等。

How is this possible? 这怎么可能?

The endpoint is me/home . 端点是me/home

https://developers.facebook.com/docs/graph-api/reference/v2.2/user/home https://developers.facebook.com/docs/graph-api/reference/v2.2/user/home

The posts that a person sees in their Facebook News Feed. 一个人在其Facebook新闻源中看到的帖子。

Make an API call to /me/home or /user_id/home where user_id is the current session user. /me/home/user_id/home进行API调用,其中user_id是当前会话用户。

You are also using the old PHP SDK 您还使用了旧的PHP SDK

/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/me/home'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Reference: https://developers.facebook.com/docs/graph-api/reference/v2.2/user/home 参考: https : //developers.facebook.com/docs/graph-api/reference/v2.2/user/home

UPDATE : The latest Graph API doc suggests the following: As of October 6th, 2015, this endpoint is no longer available. 更新 :最新的Graph API 文档提出以下建议:自2015年10月6日起,该端点不再可用。 Please consider using the /user-id/feed edge instead. 请考虑改用/ user-id / feed边缘。

This effectively means we cannot access the user news feed provided by Facebook but will have to rely on /user-id/feed as an alternative. 这实际上意味着我们无法访问Facebook提供的用户新闻供稿,而不得不依靠/ user-id / feed作为替代。

获取所有最近的通知,包括通过Graph API进行读取,请致电:

graph.facebook.com/USER_ID/notifications?include_read=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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