傳回讚好此物件的用戶清單。在讀取對專頁或用戶物件的讚好時,此端點會傳回該專頁或用戶讚好的專頁清單。
使用物件的 likes
欄位獲取讚好次數。
我們建議您使用 /object/reactions
端點獲取讚好次數(如適用)。
新版專頁體驗支援以下物件 /likes
端點:
|
total_count
的彙總數目計算和 summary
參數適用於帖子讚好。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-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 /v21.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 /v21.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 }