このオブジェクトに「いいね!」している人たちのリストを返します。ページまたはユーザーオブジェクトへの「いいね!」を読み取る際、このエンドポイントはそのページまたはユーザーが「いいね!」したページのリストを返します。
オブジェクトのlikesフィールドを使用して、「いいね!」の数を取得します。
可能であれば/object/reactionsエンドポイントを使用して「いいね!」の数を取得することをおすすめします。
以下のオブジェクトの/likesエンドポイントは、新しいページエクスペリエンスでサポートされています。
summaryパラメーターでtotal_countを使用して集計される件数だけです。likeリアクションの件数には、「いいね!」と「大切だね」のリアクションが含まれます。
total_countは「いいね!」のおおよその数を表しますが、実際に返される結果の数はプライバシー設定によって異なる場合があります。GET /{group-post-id}/likesおよびGET /{post-id}/likesエンドポイントは、v8.0以上では廃止済みであり、2020年11月2日にはすべてのバージョンで廃止される予定です。 | プロパティ名 | 説明 | 型 |
|---|---|---|
| オブジェクトに対するユーザーやページによる「いいね!」の合計数。このフィールドに応答を得るには、 |
|
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月18日T18:21:04+0000"
},
{
"name": "Calvin and Hobbes",
"id": "257573197608192",
"created_time": "2017年06月18日T18:21:02+0000"
},
{
"name": "Berkeley Breathed's Bloom County",
"id": "108793262484769",
"created_time": "2017年06月18日T18: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 /v24.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アクセス許可「いいね!」追加のための必須フィールドはありません。
成功すると、アプリは次の応答を受け取ります。
{
"success": true
}この操作は、このエンドポイントでは実行できません。
このエンドポイントを使用してページオブジェクトへの「いいね!」を削除します。
DELETE /v24.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
}