/{comment-id}
Facebook 用户可对各类内容发表 comment
。大部分图谱 API 节点拥有 /comments
连线,此连线会列出特定对象的全部评论。/{comment-id}
节点会返回单条 comment
。
此 API 支持新版公共主页体验。
一般:一般来说,查看评论需要的权限与查看评论对象所需权限相同。
回复:如果一条评论是用于回复另一条评论,则所需权限应用于父级评论的对象。
公共主页自有的评论和回复:对于公共主页拥有的所有评论或回复,如果希望响应中包含用户信息,您必须使用公共主页访问口令。
公共主页帖子评论编号格式 {page-id}_{post_id}_{comment-id}
已停用。改为使用 {pagepost-id}_{comment-id}
格式。
GET /v19.0/{comment-id} 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(
'/{comment-id}',
'{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(
"/{comment-id}",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{comment-id}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{comment-id}"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
属性名称 | 说明 | 类型 |
---|---|---|
| 评论编号 |
|
| 附加到评论的链接、视频、贴图或照片 | |
| 浏览者是否可以回复此评论 |
|
| 浏览者是否可以移除此评论 |
|
| 浏览者是否可以隐藏此评论。仅公共主页管理员可见 |
|
| 浏览者是否可以赞此评论 |
|
| 浏览者是否可以给此评论发送私密回复(仅限公共主页浏览者) |
|
| 此评论的回复数量 |
|
| 此评论的发表时间 |
|
| 此评论的作者 | |
| 此评论的点赞数 |
|
| 评论文本 |
|
| 在 |
|
| 包含照片或视频的帖子中的评论,包括动态帖子中的评论。否则此字段为空。 |
|
| 适用于评论回复,此评论为回复对象。 | |
| 适用于有私密回复的评论,让公共主页和评论作者之间进行对话(仅限公共主页浏览者) | |
| 浏览者是否点赞此评论。 |
|
当节点上存在 /comments
连线时,您可以使用该连线发布评论。
您可以通过使用以下端点删除评论:
DELETE /v19.0/{comment-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->delete(
'/{comment-id}',
array (),
'{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(
"/{comment-id}",
"DELETE",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{comment-id}",
null,
HttpMethod.DELETE,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{comment-id}"
parameters:params
HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
此 API 支持新版公共主页体验。
如要删除公共主页发布的评论,您需要:
pages_read_engagement
权限 pages_manage_engagement
权限 如要删除用户或另一个公共主页发布的评论,您需要:
pages_manage_engagement
权限 pages_read_user_content
权限 点评不属于公共主页帖子,因此公共主页无法移除回复点评的评论。
如果成功,则返回:
{ "success": true }
否则会返回相关的错误消息。
您可以通过使用以下端点编辑评论:
POST /v19.0/{comment-id} HTTP/1.1
Host: graph.facebook.com
message=This+is+a+test+comment
/* PHP SDK v5.0.0 */
/* make the API call */
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post(
'/{comment-id}',
array (
'message' => 'This is a test comment',
),
'{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(
"/{comment-id}",
"POST",
{
"message": "This is a test comment"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
Bundle params = new Bundle();
params.putString("message", "This is a test comment");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{comment-id}",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
NSDictionary *params = @{
@"message": @"This is a test comment",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{comment-id}"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
此 API 支持新版公共主页体验。
pages_read_engagement
权限 pages_manage_engagement
权限 您可以隐藏大部分帖子评论,但以下评论除外:
更新时必须提供下列字段中的其中一个:attachment_url
、attachment_id
、message
或 attachment_share_url
。
您必须提供消息或附件。附件可以是 url
、attachment_id
或者 attachment_share_url
。您可能需一并提供 id
和 url
。如果提供 attachment_share_url
,则您不可以再提供其它字段。
在更新时,您必须提供原始内容中的全部值。如果您未提供其中一个值,则更新完成后该值会遭移除。例如,假设您更新的评论包含通过 attachment_url
指定的图像,如果您在更新时未提供该图像,系统会将其移除。
更新支持 /object/comments
的发布部分所列出的字段。其中包括 attachment_url
、attachment_id
、message
和 source
。请查看该文档,获取有关这些字段的详细信息。
更新还支持此处所列的 is_hidden
字段。
名称 | 说明 | 类型 |
---|---|---|
| 评论状态是隐藏还是可见。初始帖子的发布者、公共主页管理员以及评论中所有被标记的人仍然可以看见此评论 |
|
如果成功,您会收到包含以下信息的响应。此外,此端点支持先写入后读取,并且可以即时返回由读取操作返回的任何字段。
{ "success": true }
如果不成功,系统会返回相关的错误消息。
属性名称 | 说明 | 类型 |
---|---|---|
/comments | 回复此评论的评论。 | Edge<Comment> |
/likes | 赞此评论的用户。 | Edge<Profile> |
/reactions | 给此帖子留下心情的用户。 | Edge<Reaction> |
/private_replies | 用于给此评论发送私密消息(仅限公共主页浏览者)。 | Edge<Message> |