返回赞此对象的用户列表。在读取对公共主页或用户对象的赞时,此端点会返回该公共主页或用户赞的公共主页列表。
使用对象的 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 }