/{comment-id}
A comment
can be made on various types of content on Facebook. Most Graph API nodes have a /comments
edge that lists all the comments on that object. The /{comment-id}
node returns a single comment
.
This API is supported for New Page Experience.
General - To read a comment, you generally need the same permissions as required for viewing the object that the comment was added to.
Replies - If this is a comment that is a reply to another comment, the permissions required apply to the object that the parent comment was added to.
Page owned Comments and Replies — For any comments or replies owned by (on) a Page, you must use a Page access token if you want User information to be included in the response.
The Page Post comment ID format, {page-id}_{post_id}_{comment-id}
, has been deprecated. Use the {pagepost-id}_{comment-id}
format instead.
GET /v21.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
}];
Property Name | Description | Type |
---|---|---|
| The comment ID |
|
| Link, video, sticker, or photo attached to the comment | |
| Whether the viewer can reply to this comment |
|
| Whether the viewer can remove this comment |
|
| Whether the viewer can hide this comment. Only visible to a page admin |
|
| Whether the viewer can like this comment |
|
| Whether the viewer can send a private reply to this comment (Page viewers only) |
|
| Number of replies to this comment |
|
| The time this comment was made |
|
| The person that made this comment | |
| Number of times this comment was liked |
|
| The comment text |
|
| An array of Profiles tagged in |
|
| The comment on a post that contains a photo or video, including those in dynamic posts. Otherwise, this is empty. |
|
| For comment replies, this the comment that this is a reply to. | |
| Comment permalink URL. If the calling app has only the Page Public Content Access feature, will not be returned in version 20.0+ queries. This change applies to all version queries starting August 19, 2024. |
|
| For comments with private replies, gets conversation between the Page and author of the comment (Page viewers only) | |
| Whether the viewer has liked this comment. |
|
You can publish comments by using the /comments
edge when it is present on a node.
You can delete a comment by using the following endpoint:
DELETE /v21.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
}];
This API is supported for New Page Experience.
To delete a comment posted by a Page, you will need:
pages_read_engagement
permission pages_manage_engagement
permission To delete a comment posted by a User or another Page, you will need:
pages_manage_engagement
permission pages_read_user_content
permission Reviews are not Page posts, so comments on reviews can not be removed by a Page.
If successful:
{ "success": true }
Otherwise a relevant error message will be returned.
You can edit a comment by using the following endpoint:
POST /v21.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
}];
This API is supported for New Page Experience.
pages_read_engagement
permission pages_manage_engagement
permission You can hide most comments on Posts with the following exceptions:
One of attachment_url
, attachment_id
, message
, or attachment_share_url
must be provided when updating.
You must include either a message or an attachment. An attachment can be either a url
, an attachment_id
, or an attachment_share_url
. You may include an id
and a url
together. If you include an attachment_share_url
, you must not include the others.
When updating you must include any values that were on the original content. If you do not include one of them it will be removed from the content after the update. For example, if you update a comment that has an image that was specified via attachment_url
and you don't include it in the update the image will be removed.
Updating supports the fields listed on the publishing section of the /object/comments
. This includes the attachment_url
, attachment_id
, message
and source
. Please see that document for details on those fields.
Updating also supports the is_hidden
field, documented here.
Name | Description | Type |
---|---|---|
| Whether this comment is hidden or visible. The original poster can still see the comment, along with the page admin and anyone else tagged in the comment |
|
If successful, you will receive a response with the following information. In addition, this endpoint supports read-after-write and can immediately return any fields returned by read operations.
{ "success": true }
If unsuccessful, a relevant error message will be returned.
Property Name | Description | Type |
---|---|---|
/comments | Comments that reply to this comment. | Edge<Comment> |
/likes | People who like this comment. | Edge<Profile> |
/reactions | People who have reacted to this post. | Edge<Reaction> |
/private_replies | Used to send private message reply to this comment (Page viewers only). | Edge<Message> |