그래프 API 버전

/{object-id}/likes

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

읽기

이 개체에 좋아요를 누른 사용자의 리스트를 반환합니다. 페이지 또는 사용자 개체에 누른 좋아요를 읽을 경우 이 엔드포인트는 해당 페이지 또는 사용자가 좋아요를 누른 페이지의 리스트를 반환합니다.

개체의 likes 필드를 사용하여 좋아요 개수를 가져옵니다.

좋아요를 가져올 경우 가능하면 /object/reactions 엔드포인트를 사용하는 것이 좋습니다.

새로운 페이지 환경

다음의 개체 /likes 엔드포인트가 새 페이지 환경에 지원됩니다.

  • 사용자

요구 사항

  • 개체의 좋아요를 보려면 해당 개체를 보는 데 필요한 것과 동일한 요구 사항이 필요합니다.

제한 사항

  • summary 매개변수가 포함된 total_count를 사용하는 집계된 합계만 게시물 좋아요에 제공됩니다.
  • like 공감 수에는 '좋아요'와 '힘내요' 공감이 포함됩니다.
  • total_count는 좋아요의 대략적인 개수를 나타내지만 반환된 실제 개수는 공개 범위 설정에 따라 달라질 수 있습니다.
  • GET /{group-post-id}/likesGET /{post-id}/likes 엔드포인트는 v8.0 이상에서 사용 중단되었고 2020년 11월 2일부터 모든 버전에서 사용 중단됩니다.

필드

속성 이름 설명 유형

total_count

개체의 사용자 및 페이지 좋아요 합계. 이 필드가 반환되려면 요청에 summary=true 매개변수와 값을 포함해야 합니다.

int32

사용 예시

요청 샘플
curl -i -X GET "https://graph.facebook.com/{object-id}
  ?fields=likes.summary(true)
  &access_token={access-token}"

응답 샘플

  {
  "likes": {
    "data": [
      {
        "name": "Bill the Cat",
        "id": "155111347875779",
        "created_time": "2017-06-18T18:21:04+0000"
      },
      {
        "name": "Calvin and Hobbes",
        "id": "257573197608192",
        "created_time": "2017-06-18T18:21:02+0000"
      },
      {
        "name": "Berkeley Breathed's Bloom County",
        "id": "108793262484769",
        "created_time": "2017-06-18T18:20:58+0000"
      }
    ],
    "paging": {
      "cursors": {
        "before": "Nzc0Njg0MTQ3OAZDZD",
        "after": "NTcxODc1ODk2NgZDZD"
      },
      "next": "https://graph.facebook.com/vX.X/me/likes?access_token=user-access-token&pretty=0&summary=true&limit=25&after=NTcxODc1ODk2NgZDZD"
    },
    "summary": {
      "total_count": 136
    }
  },
  "id": "user-id"
}

게시

개체에 좋아요를 누릅니다.

새로운 페이지 환경

다음의 개체 /likes 엔드포인트가 새 페이지 환경에 지원됩니다.

POST /v19.0/{object-id}/likes HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{object-id}/likes',
    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(
    "/{object-id}/likes",
    "POST",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{object-id}/likes",
    null,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{object-id}/likes"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

권한

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

제한 사항

  • 페이지도 (API 또는 Facebook.com을 통해) 개체에 좋아요를 누를 수 있어야 합니다.
  • 해당 개체는 페이지가 좋아요를 이미 누르지 않은 것이어야 합니다.
  • 페이지가 개체에 이미 공감했을 경우(멋져요, 슬퍼요) 좋아요를 누를 수 있더라도 공감이 변경되지 않습니다.
  • 페이지 리뷰에 좋아요를 누르는 것은 지원되지 않습니다.

필드

좋아요를 추가하는 데 필요한 필드가 없습니다.

응답

성공할 경우 앱은 다음과 같은 응답을 받습니다.

{
  "success": true
}

업데이트

이 엔드포인트에서는 이 작업을 수행할 수 없습니다.

삭제

이 엔드포인트를 사용하여 페이지 개체에서 좋아요를 삭제합니다.

DELETE /v19.0/{object-id}/likes 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(
    '/{object-id}/likes',
    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(
    "/{object-id}/likes",
    "DELETE",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{object-id}/likes",
    null,
    HttpMethod.DELETE,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{object-id}/likes"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

권한

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

제한 사항

  • 사용자 또는 페이지는 자신의 likes만 삭제할 수 있습니다.
  • 이 개체는 이미 좋아요를 누른 상태여야 합니다.
  • 페이지 리뷰의 좋아요를 삭제하는 것은 지원되지 않습니다.

필드

이 엔드포인트에 대한 필드가 없습니다.

응답

성공할 경우 앱은 다음과 같은 응답을 받습니다.

{
  "success": true
}