/{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 /v21.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 /v21.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
}];
Parameter | Description |
---|---|
| A summary of metadata about the comments on the object. Importantly this metadata includes |
| 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.
|
An array of Comment objects in addition to the following fields when summary
is true
in the request.
Field | Description |
---|---|
| Order in which comments were returned.
|
| The count of comments on this node. It is important to note that this value changes depending on the
Note: |
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 /v21.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.