/{object-id}/comments
This reference describes the /comments
edge that is common to multiple Graph API nodes. The structure and operations are the same for each node. The following objects have a /comments
edge:
It is possible for comment objects to have a /comments
edge, which is called comment replies
. The structure is the same for these, but attention should be paid to the modifiers
for these edges.
Returns a comment on an object.
The id
field for the /PAGEPOST-ID/comments
endpoint will no longer be returned for apps using the Page Public Content Access feature
. To access the comment IDs for a Page post you must be able to perform the MODERATE task
on the Page being queried. This change is in effect for v11.0+ and will be implement for all versions on September, 7, 2021.
The following objects /comments
endpoint are supported for New Page Experience:
filter
parameter to stream
or use the order
field./comments
endpoint returns empty data if you read it with a User access token
: id
field for the /PAGEPOST-ID/comments
endpoint
will no longer be returned for apps using the Page Public Content Access feature
. To access the comment IDs for a Page post you must be able to perform the MODERATE task
on the Page being queried.For objects that have tens of thousands of comments, you may encounter limits while paging . Learn more about paging in our Using the Graph API Guide .
GET /v25.0/{object-id}/comments 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}/comments',
'{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}/comments",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{object-id}/comments",
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}/comments"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
GET /v25.0/{object-id}/comments?summary=1&filter=toplevel 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}/comments?summary=1&filter=toplevel',
'{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}/comments",
{
"summary": true,
"filter": "toplevel"
},
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
Bundle params = new Bundle();
params.putBoolean("summary", true);
params.putString("filter", "toplevel");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{object-id}/comments",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
NSDictionary *params = @{
@"summary": @YES,
@"filter": @"toplevel",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{object-id}/comments"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
summary
A summary of metadata about the comments on the object. Importantly this metadata includes order
which indicates how the comments are being sorted.
filter
If a person can reply to a comment, you can filter comments based on top level comments, comments that are made directly on the post, or the chronological order of all comments.
toplevel
- This is the default. It returns all top-level comments in chronological order, as ordered on Facebook. This filter is useful for displaying comments in the same structure as they appear on Facebook.stream
- All-level comments in chronological
order. This filter is useful for comment moderation tools where it is helpful to see a chronological list of all comments.An array of Comment objects
in addition to the following fields when summary
is true
in the request.
order
Order in which comments were returned.
chronological
: Comments sorted by the oldest comments first.reverse_chronological
: Comments sorted by the newest comments first. total_count
The count of comments on this node. It is important to note that this value changes depending on the filter
being used (where comment replies are available):
filter
is stream
then total_count
will be a count of all comments (including replies) on the node.filter
is toplevel
then total_count
will be a count of all top-level comments on the node.Note: total_count
can be greater than or equal to the actual number of comments returned due to comment privacy or deletion.
Publish new comments to any object.
The following objects /comments
endpoint are supported for New Page Experience:
MODERATE
task on the Pagepages_manage_engagement
permissionNote, the can_comment
field on individual comment objects
indicates whether it is possible to reply to that comment.
POST /v25.0/{object-id}/comments 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(
'/{object-id}/comments',
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(
"/{object-id}/comments",
"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(),
"/{object-id}/comments",
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:@"/{object-id}/comments"
parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
| Name | Description |
|---|---|
| |
An optional ID of a unpublished photo (see |
| |
The URL of a GIF to include as a animated GIF comment. One of |
| |
The URL of an image to include as a photo comment. One of |
| |
A photo, encoded as form data, to use as a photo comment. One of |
| |
The comment text. One of Mention other Facebook Pages in your Usage of this feature is subject to review . |
If successful, you will receive a JSON response with the newly created comment ID. In addition, this endpoint supports read-after-write and can immediately return any fields returned by read operations.
{
"id": "{comment-id}"
}
You can't update using this edge.
You can't delete using this edge.
Delete individual comments using the /comment-id endpoint .