如何获取Facebook个人资料图片并使用facebook api将其存储在我们的数据库中?

时间:2015-11-19 14:16:58

标签: php mysql facebook codeigniter facebook-graph-api

我正在使用codeigniter facebook库访问facebook用户detalis。我已经存储了电子邮件,名字,姓氏。但我使用相同的库我没有得到正确的个人资料图片。请查看我的以下代码

$this->load->library('facebook_new/facebook');
    $user = $this->facebook->getUser();
    if(!empty($user)) {
        try {
            //$uid = $facebook->getUser()
            //$permissions = $this->facebook->api("/me/permissions"); 
            $user_profile = $this->facebook->api('/me?fields=id,first_name,last_name,picture,name,email');
            //print_r($user_profile);exit;
        } catch(FacebookApiException $e) {
            error_log($e);
            $user = null;
        }
    } else {
        $this->facebook->destroySession();
    }

访问后,我获取的值为

    Array
(
[id] => xxxxx
[first_name] => add
[last_name] => adsfasdf
[picture] => Array
    (
        [data] => Array
            (
                [is_silhouette] => 
                [url] => https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xft1/v/t1.0-1/adsfadf/asdfasdfasdfasdfn.jpg?oh=85d5d12f5b7d379dd9d20bb1ecdafeb2&oe=56E638EA&__gda__=asdfasdf
            )

    )

[name] => xxx xxx
[email] => wqerqwer@asdfasdf.com
)

0 个答案:

没有答案