我正在使用facebook php sdk,我关注这个网站http://www.benmarshall.me/facebook-sdk-php-v4/来使用它。
我正在做两种方式来获取Facebook用户信息和图像。
这就是我获取用户公开个人资料信息的方式
$request = new FacebookRequest($session, 'GET', '/me' );
$request = $request->execute();
// Get response as an array
$picture = $request->getGraphObject()->asArray();
返回
Array
(
[id] => ***********
[email] => *************
[first_name] => Åahin
[gender] => male
[last_name] => Deniz
[link] => https://www.facebook.com/app_scoped_user_id/**********/
[locale] => tr_TR
[name] => Åahin Deniz
[timezone] => 3
[updated_time] => 2014-08-17T00:53:21+0000
[verified] => 1
)
这是个人资料图片连接。
$request = new FacebookRequest($session, 'GET', '/me/picture?type=large&redirect=false' );
$request = $request->execute();
// Get response as an array
$picture = $request->getGraphObject()->asArray();
返回此
Array
(
[url] => https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/*****************.jpg
[is_silhouette] =>
)
Array
(
[id] => ***********
[email] => *************
[first_name] => Åahin
[gender] => male
[last_name] => Deniz
[link] => https://www.facebook.com/app_scoped_user_id/**********/
[locale] => tr_TR
[name] => Åahin Deniz
[timezone] => 3
[updated_time] => 2014-08-17T00:53:21+0000
[verified] => 1
[url] => https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/v/*****************.jpg
)
$User = new FacebookRequest($session, 'GET', '/me' );
$Picture = new FacebookRequest($session, 'GET', '/me/picture?type=large&redirect=false' );
$User=array_merge($User->execute()->getGraphObject()->asArray(),$Picture->execute()->getGraphObject()->asArray());