PHP,提取Facebook用户的图像并将其保存到数据库中


PHP, extract facebook user's image and save it into db

我的网站使用Facebook登录api让人们轻松登录。

如果我知道用户的脸书ID号,我就可以得到用户的脸书个人资料图片。

$fb_id = $this->input->post('fb_id');
$fb_image_url = 'https://graph.facebook.com/'.$fb_id.'/picture?type=large';

因此,如果我有正确的ID号并在网站上发布URL,它会重定向到jpg地址。

https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/274661_1171545457_647564606.jpg

因此,我无法使用第一个地址将图像文件保存到数据库中。

在使用 $fb_image_url 之前,我需要做一些事情来获取真实的图像地址。

有没有办法使用 PHP 获取最终地址?

file_get_contents('https://graph.facebook.com/$fb_id/picture?type=large.');应该能够抓取img内容。 你试过吗?