Facebook Api - 保存个人资料图片

时间:2018-05-28 13:20:50

标签: php mysql facebook facebook-graph-api

尝试从facebook API保护配置文件img。这段代码将获取url / downloadlink,但现在我希望它将它保存在服务器上的某个地方,这样我就可以将它从数据库中取出并显示在某处。我以为我可能需要使用php copy功能,但我不确定。我也已经用谷歌搜索了它,但那是旧版本的facebook API。

$oAuth2Client = $FB->getOAuth2Client();
if (!$accessToken->isLongLived())
    $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);

$response = $FB->get("/me?fields=id, first_name, last_name, email,gender,link, birthday,picture.type(large)", $accessToken);
$userData = $response->getDecodedBody();

$fb_foto_url = $userData['picture']['data']['url']; 

$voornaam= $app->get_klant_fb($userData['first_name']);
$_SESSION['voornaam'] = $userData['first_name'];
$_SESSION['achternaam'] = $userData['last_name'];

$fb_fotoUrl = $app->saving_fb_foto($userData['picture']['data']['url']);

//data ophalen
$klant= $app->get_klant_fb($userData['id']);
if($klant['id'] > 0) {
    //sessie klant zetten
    $_SESSION['klant_id'] = $klant['id'];
} else {
    //klant aanmaken
    unset($query);
    $query['oauth_uid']     = $userData['id'];
    $query['ledenpagina_id']= $_SESSION['ledenpagina_id'];
    $query['voornaam']      = $userData['first_name'];
    $query['achternaam']    = $userData['last_name'];
    $query['emailadres']    = $userData['email'];
    $query['geboortedatum'] = $userData['birthday'];
    $query['gender']        = $userData['gender']; 
    $query['link']          = $userData['link'];
    $query['foto']          = $userData['picture']['data']['url'];

    $app->insert_query('klanten', $query);

    $klant= $app->get_klant_fb($userData['id']);
    if($klant['id'] > 0) {
        $_SESSION['klant_id'] = $klant['id'];  
    }
}

0 个答案:

没有答案