Connecting Laravel with facebook SDK


Connecting Laravel with facebook SDK

我正在尝试连接Facebook,并获得用户名,电子邮件和位置。

我在理解权限和范围方面有困难。我的代码只返回这个

Array
(
    [name] => Ben Shepherd
    [id] => 123xxxxxxxxxx
)
这是我的代码
public function facebookRedirect()
{
    $facebook = new Facebook(Config::get('facebook'));
    $params = array(
        'redirect_uri' => URL::route('takepart.facebook.callback'),
        'scope' => 'public_profile'
    );
    return Redirect::to($facebook->getLoginUrl($params));
}
public function facebookCallback()
{
    $code = Input::get('code');
    if (strlen($code) == 0) return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
    $facebook = new Facebook(Config::get('facebook'));
    $uid = $facebook->getUser();
    if ($uid == 0) return Redirect::to('/')->with('message', 'There was an error');
    $me = $facebook->api('/me');
    Helper::pr($me);
}

https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/

更少的默认字段,更快的性能:为了帮助提高移动网络连接的性能,我们减少了API默认返回的字段数量。您现在应该使用?fields=field1,field2语法来声明您希望API返回的所有字段。

,

$me = $facebook->api('/me');

需要调整以获取您感兴趣的特定配置文件字段。