Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从facebook open graph获取页面照片喜好_Php_Facebook_Api_Facebook Graph Api - Fatal编程技术网

Php 从facebook open graph获取页面照片喜好

Php 从facebook open graph获取页面照片喜好,php,facebook,api,facebook-graph-api,Php,Facebook,Api,Facebook Graph Api,使用PHP,我可以使用如下URL从facebook页面检索图像: https://graph.facebook.com/v2.7/albumid/photos?access_token=XXXXXXX&debug=all&fields=images&format=json&method=get&pretty=1&suppress_http_code=1 /albumd-id/photos?fields=images,likes.summary(1

使用PHP,我可以使用如下URL从facebook页面检索图像:

https://graph.facebook.com/v2.7/albumid/photos?access_token=XXXXXXX&debug=all&fields=images&format=json&method=get&pretty=1&suppress_http_code=1
/albumd-id/photos?fields=images,likes.summary(1).limit(0)

但是我怎样才能得到每张照片的喜欢数呢?上面的URL仅返回图像URL、宽度和高度。我正在寻找每个页面照片(不是用户照片)的喜欢数量。

从您的API中,您将获得每个照片的照片ID,您必须使用该照片ID

试试这个

/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{photo-id}/likes'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

GET /v2.8/{photo-id}/likes HTTP/1.1

从API中,您将获得必须使用该照片ID的每张照片的照片ID

试试这个

/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{photo-id}/likes'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

GET /v2.8/{photo-id}/likes HTTP/1.1

但是我怎样才能得到每张照片的喜欢数呢

通过请求相关字段,与您已经对
图像执行的操作相同:

/albumd-id/photos?fields=images,likes
这会给你个人喜欢的。由于您对这些内容不感兴趣,而只对总数感兴趣,因此添加summary=1和限制0,使用字段扩展语法如下所示:

https://graph.facebook.com/v2.7/albumid/photos?access_token=XXXXXXX&debug=all&fields=images&format=json&method=get&pretty=1&suppress_http_code=1
/albumd-id/photos?fields=images,likes.summary(1).limit(0)
但是我怎样才能得到每张照片的喜欢数呢

通过请求相关字段,与您已经对
图像执行的操作相同:

/albumd-id/photos?fields=images,likes
这会给你个人喜欢的。由于您对这些内容不感兴趣,而只对总数感兴趣,因此添加summary=1和限制0,使用字段扩展语法如下所示:

https://graph.facebook.com/v2.7/albumid/photos?access_token=XXXXXXX&debug=all&fields=images&format=json&method=get&pretty=1&suppress_http_code=1
/albumd-id/photos?fields=images,likes.summary(1).limit(0)