php中的imagecreatefromjpeg禁止403

时间:2016-05-07 11:15:24

标签: php image facebook-graph-api

我要合并两张图片一张是facebook的用户个人资料图片,我使用graph API而其他图片是我服务器中的主机。
当我尝试imagecreatefromjpeg为个人资料照片时,它会抛出Forbidden Error 403

 $url='https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c69.165.576.576/s50x50/12661918_1679202092322313_2752077154994097120_n.jpg?oh=f3c405146a3be5b613f046672538949c'; 

  imagecreatefromjpeg($url);

如果facebook不允许这样做,那么为什么其他网站如meaww.com和其他许多网站都会这样做。
我怎样才能做到这一点。

1 个答案:

答案 0 :(得分:0)

你可以从facebook获取你的图像像base64这样的二进制文件,也可以在你的主机上获得你的图像相同的图像,然后你可以使用imagecreatefromstring函数,之后使用下面的函数来合并两个图像。 imagecopymerge(资源$ dst_im,资源$ src_im,int $ dst_x,int $ dst_y,int $ src_x,int $ src_y,int $ src_w,int $ src_h,int $ pct)