图谱 API 版

/{object-id}/sharedposts

本参考文档将介绍多个图谱 API 节点常用的 /sharedposts 连线。每个节点的架构和操作都相同。下列对象均有 sharedposts 连线:

  • 主页帖子
  • 帖子
  • 用户

读取

权限

  • 具有 user_posts 权限的用户访问口令,适用于在隐私设置纳入考虑后,能够查看帖子的用户。在两种情况下,帖子将被退回:(a) 帖子由应用创建,(b) 帖子的创作者为应用授予了 user_posts 权限。

功能权限

名称说明

公共主页公开内容访问权限

这是一个必需的功能权限

限制

  • /{album-id}/sharedposts 不可用。
  • GET /{photo-id}/sharedposts 端点在 v8.0 及之后的版本中已停用。

示例

图谱 API 探索工具
GET /v19.0/{object-id}/sharedposts HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{object-id}/sharedposts',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{object-id}/sharedposts",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{object-id}/sharedposts",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{object-id}/sharedposts"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

字段

代表每次分享的帖子对象的清单。

发布

您无法使用图谱 API 发布对象的分享。

删除

您无法使用图谱 API 删除对象的分享。