그래프 API 버전

/{object-id}/comments

이 참고 자료에서는 여러 가지 그래프 API 노드에서 일반적으로 사용하는 /comments 에지에 대해 설명합니다. 각 노드의 구조와 동작은 동일합니다. 다음 개체에는 /comments 에지가 있습니다.

댓글 개체가 /comments 에지(댓글 답장)를 가질 수도 있습니다. 이러한 에지도 구조는 동일하지만 해당 에지의 수정자에 주의해야 합니다.

읽기

개체에서 댓글을 반환합니다.

/PAGEPOST-ID/comments 엔드포인트의 id 필드는 더 이상 페이지 전체 공개 콘텐츠 액세스 기능을 사용하는 앱에 반환되지 않습니다. 페이지 게시물의 댓글 ID에 액세스하려면 쿼리 대상 페이지에서 MODERATE 작업을 실행할 수 있어야 합니다. 이 변경 사항은 v11.0+에 적용되며 2021년 9월 7일부터 모든 버전에 구현됩니다.

새로운 페이지 환경

다음 개체 /comments 엔드포인트가 새로운 페이지 환경에서 지원됩니다.

  • 사진첩
  • 댓글
  • 링크
  • 페이지
  • 페이지 게시물
  • 사진
  • 게시물
  • 게시물 댓글

권한

  • 상위 개체의 댓글을 보려면 해당 개체를 보는 데 필요한 것과 동일한 권한이 있어야 합니다.

제한 사항

  • 다른 사용자의 프로필 정보와 댓글은 사용자 게시물, 사진, 사진첩, 동영상, 좋아요, 공감에 액세스할 때는 반환되지 않습니다. 단, 해당 사용자가 승인한 경우에는 예외입니다.
  • 쿼리에서 반환된 댓글은 기본 필터링을 기반으로 합니다. 권한에 따라 반환될 수 있는 모든 댓글을 가져오려면 filter 매개변수를 stream으로 설정하거나 order 필드를 사용합니다.
  • 새로운 페이지는 새로운 페이지나 이전 페이지에 페이지 이름으로 댓글을 남길 수 있습니다. 그러나 이전 페이지는 새로운 페이지에 댓글을 남길 수 없습니다.
  • 다음 노드의 경우 사용자 액세스 토큰으로 읽으면 /comments 엔드포인트가 빈 데이터를 반환합니다.
  • /PAGEPOST-ID/comments 엔드포인트id 필드는 더 이상 페이지 전체 공개 콘텐츠 액세스 기능을 사용하는 앱에 반환되지 않습니다. 페이지 게시물의 댓글 ID에 액세스하려면 쿼리 대상 페이지에서 MODERATE 작업을 실행할 수 있어야 합니다.
  • 수만 개의 댓글이 달린 개체의 경우 페이지 매김에 제한이 적용될 수 있습니다. 페이지 매김에 대한 자세한 정보는 그래프 API 사용 가이드를 참조하세요.

그래프 API 탐색기
GET /v19.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 /v19.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

부울

개체의 댓글에 대한 메타데이터 요약. 특히 이 메타데이터에는 댓글의 정렬 순서를 나타내는 order가 포함됩니다.

filter

enum { toplevel, stream }

사용자가 댓글에 답글을 달 수 있는 경우 최상위 댓글, 게시물에 직접 작성한 댓글 또는 모든 댓글의 시간 순서를 기준으로 댓글을 필터링할 수 있습니다.

  • toplevel - 기본값입니다. Facebook에 표시된 순서대로 시간에 따라 모든 최상위 댓글을 반환합니다. 이 필터는 Facebook에 나타나는 것과 동일한 구조로 댓글을 표시하는 데 유용합니다.
  • stream - chronological 순서로 모든 수준 댓글을 표시합니다. 이 필터는 모든 댓글의 시간 순서 리스트를 보는 데 도움이 되는 댓글 조정 도구로 유용합니다.

필드

요청에서 summary 코드가 true일 경우 다음 필드와 함께 댓글 개체 배열을 포함합니다.

필드 설명

order

enum { chronological, reverse_chronological }

댓글이 반환되는 순서

  • chronological: 가장 오래된 댓글 먼저 정렬
  • reverse_chronological: 가장 최신 댓글 먼저 정렬

total_count

int32

이 노드에 달린 댓글 수. 이 값은 사용되는 filter에 따라 변경된다는 것을 기억해야 합니다(댓글 답장을 이용할 수 있는 경우).

  • filter 코드가 stream 코드라면 total_count 코드는 노드의 모든 댓글 개수(답장 포함)가 됩니다.
  • filter 코드가 toplevel 코드라면 total_count 코드는 노드의 모든 최상위 댓글 개수(답장 포함)가 됩니다.

참고: total_count 코드는 댓글 공개 범위 또는 삭제로 인해 실제 반환된 댓글 수보다 크거나 같을 수 있습니다.

게시

아무 개체에 새 댓글을 게시합니다.

새로운 페이지 환경

다음 개체 /comments 엔드포인트가 새로운 페이지 환경에서 지원됩니다.

  • 댓글
  • 페이지 게시물
  • 사진
  • 게시물
  • 게시물 댓글
  • 동영상

권한

  • 페이지에서 MODERATE 작업을 수행할 수 있는 사용자가 요청한 페이지 액세스 토큰
  • pages_manage_engagement 권한

댓글 개체can_comment 필드는 해당 댓글에 대한 답장이 가능한지 나타냅니다.

POST /v19.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
}];

필드

이름 설명

attachment_id

문자열

사진 댓글로 포함하기 위해 Facebook에 업로드했으나 비공개 상태인 사진(/{user-id}/photosno_story 필드 참조)의 선택적 ID입니다. 게시할 때 attachment_id, attachment_share_url, attachment_url, message 또는 source 중 하나를 제공해야 합니다.

attachment_share_url

문자열

애니메이션 GIF 댓글로 포함할 GIF의 URL입니다. 게시할 때 attachment_id, attachment_share_url, attachment_url, message 또는 source 중 하나를 제공해야 합니다.

attachment_url

문자열

사진 댓글로 포함할 이미지의 URL입니다. 게시할 때 attachment_id, attachment_share_url, attachment_url, message 또는 source 중 하나를 제공해야 합니다.

source

multipart/form-data

양식 데이터로 인코딩한 사진이며 사진 댓글로 사용됩니다. 게시할 때 attachment_id, attachment_share_url, attachment_url, message 또는 source 중 하나를 제공해야 합니다.

message

문자열

댓글 텍스트. 게시할 때 attachment_id, attachment_share_url, attachment_url, message 또는 source 중 하나를 제공해야 합니다.

다음 구문을 사용하여 message 텍스트에서 다른 Facebook 페이지를 언급합니다.

@[page-id]

이 기능을 사용하려면 검수를 받아야 합니다.

반환 유형

성공할 경우 새롭게 생성된 댓글 ID가 포함된 JSON 응답을 수신합니다. 또한 이 엔드포인트는 쓰기 후 읽기를 지원하고 읽기 작업으로 반환된 모든 필드를 즉시 반환할 수 있습니다.

{
  "id": "{comment-id}"
}

업데이트

이 에지를 사용하여 업데이트할 수 없습니다.

삭제

이 에지를 사용하여 삭제할 수 없습니다.

/comment-id 엔드포인트를 사용하여 개별 댓글을 삭제합니다.