傳回對此物件按讚的用戶名單。讀取粉絲專頁或用戶物件的按讚次數時,這個端點會傳回該粉絲專頁或用戶按讚的粉絲專頁清單。
使用物件的 likes 欄位來取得按讚次數。
建議您使用 /object/reactions 端點來取得按讚次數(如適用)。
下列物件的 /likes 端點支援新版粉絲專頁體驗:
|
summary 參數的 total_count 才能彙總貼文的按讚次數。like 心情計數包括「讚」和「加油」心情。
total_count 代表按讚次數的估略值,但實際傳回的次數可能因隱私設定而不同。GET /{group-post-id}/likes 和 GET /{post-id}/likes 端點在 8.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-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 /v25.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 /v25.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
}