我正在使用一个名为 yii-facebook-opengraph 的扩展程序,用于从 facebook 登录。我正在后端获取详细信息并将它们保存在数据库中。在这里,我也在获取用户图像,当我将用户图像保存在文件夹中时,它会保存图像,但大小为 0kb。
我正在使用的代码如下:
$image = "http://graph.facebook.com/".$IsUser->social_key."/picture?type=normal";
$img_file = file_get_contents($image);
$file_loc = Yii::app()->basePath.'/../images/userimag/'.$IsUser->id.'.jpg';
$file_handler=fopen($file_loc,'w');
if(fwrite($file_handler,$img_file)==false){
echo 'error';
}
fclose($file_handler);
$model->profile_image = $IsUser->id.'.jpg';
$model->save(false);
当我打印图像 url $image 我得到图像,但是当我打印 $img_file 它显示为空