Laravel socialite facebook头像

bas*_*abi 6 php facebook facebook-graph-api laravel laravel-socialite

我使用Laravel 5.2和Socialite.我能够提取出用户的详细信息,但问题是如果我将头像注入其中,则无法正确显示头像src.

社交网站返回一个对象,我可以使用它$facebookDetails->getAvatar()返回一个像这样的值https://graph.facebook.com/v2.6/123456789/picture?type=normal

如果我在图像中回显此值src,它将看起来像这样.

<img src="https://graph.facebook.com/v2.6/123456789/picture?type=normal" />

这似乎不是图像的实际URL,因为当我在浏览器上输入它时,它会将我重定向到"实际"图像并显示图像.

如何在img标签上显示图像以显示实际图像?

Nad*_*035 9

只需使用file_get_contents函数获取数据并处理检索到的数据.

在控制器中

use File; 

$fileContents = file_get_contents($user->getAvatar());
File::put(public_path() . '/uploads/profile/' . $user->getId() . ".jpg", $fileContents);

//To show picture 
$picture = public_path('uploads/profile/' . $user->getId() . ".jpg");
Run Code Online (Sandbox Code Playgroud)