从facebook图形api保存远程图像

时间:2015-09-29 23:16:06

标签: php facebook http laravel intervention

知道什么是错的吗? 我最终得到1bytes文件,他们错了。使用干预图像& PHP。尝试了许多方法来获得它但没有...如果我只想显示它有效但我无法保存图片......

$avatar_url     = 'http://graph.facebook.com/' . $id . '/picture?type=square&width=140&height=140&redirect=false';
                    $avatar_pic_url = json_decode(file_get_contents($avatar_url), true)['data']['url'];
                    dd($avatar_pic_url);
                    $avatar         = Image::make($avatar_pic_url);
                    $extension      = 'jpg';
                    // save it
                    $destinationPath        = 'uploads/avatars/';
                    $filename               = uniqid(). '.' . $extension;
                    $path_to_temp_image     = $avatar->dirname . '/' . $avatar->filename;
                    $key                    = $destinationPath . $filename;
                    // Upload avatar to remote storage
                    $uploadSuccess = Storage::put($key, $path_to_temp_image);

0 个答案:

没有答案