Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.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 下载带有大小和访问令牌的用户配置文件照片_Php_Facebook Graph Api - Fatal编程技术网

Php 下载带有大小和访问令牌的用户配置文件照片

Php 下载带有大小和访问令牌的用户配置文件照片,php,facebook-graph-api,Php,Facebook Graph Api,我正在使用以下脚本下载照片 $data = file_get_contents($photos->pic_big); $file = fopen($image_save, 'w+'); fputs($file, $data); fclose($file); 但我现在想下载的图像大小根据我的使用。Facebook为此提供了一个选项 https://graph.facebook.com/shaverm/picture?width=200&height=200 我可以用用户id替换用

我正在使用以下脚本下载照片

$data = file_get_contents($photos->pic_big);
$file = fopen($image_save, 'w+');
fputs($file, $data);
fclose($file);
但我现在想下载的图像大小根据我的使用。Facebook为此提供了一个选项

https://graph.facebook.com/shaverm/picture?width=200&height=200
我可以用用户id替换用户名以获得重新调整大小的图片吗?
如何用PHP编写脚本将照片下载到我的服务器?

是的,您可以用用户ID替换用户名

用户名是Facebook Graph中对象ID的真实别名。试试这个:


您可以使用curl:.下载e.x的照片。

我需要传递任何访问令牌吗?不。配置文件图片在图形中是公共的。就像Facebook上的许多API一样,访问图片的速度是有限的,以防止滥用。当一个应用程序变得稍微流行时,应用程序在图片上遇到速率限制是一个非常常见的问题。避免速率限制问题的最佳方法是随请求一起传递access\u token=token参数。为什么您更喜欢curl而不是file\u get\u内容?由于性能原因,需要设置许多选项,多个请求(同时)等等。