doule6314 2016-01-09 05:33
浏览 56

Facebook api getEmail()无效

i'm using laravel 5 Socialite and this to create social login https://github.com/laravel/socialite. When i use this function and when i ran into this $facebook->getEmail(); the email i get it's null

 public function FacebookInfo()
    {
        $facebook = Socialite::driver('facebook')->user();
        $user= new User();
        $user-> username =$facebook->getNickname();
        $user-> full_name =$facebook->getName();
        $user-> avatar=$facebook->getAvatar();
        $user-> email =$facebook->getEmail();
        $user-> remember_token =$facebook->token;
        $user ->level=1;
        $user-> total_post = 0;
        $user->save();
        return redirect()->intended('/');
    }

So any suggest for this problem? Thanks in advanced

  • 写回答

1条回答 默认 最新

  • dongyuluan7494 2016-01-09 06:28
    关注

    You have to mention what all fields do you want from Facebook. You can do this by adding a scope while redirecting to Facebook for authentication like below,

    return Socialite::driver('facebook')->scopes(['public_profile','email', 'user_friends'])->redirect();
    

    You can learn more about Facebook permissions here.

    P.S. Now Facebook also allows mobile number to create an account instead of an email. In that case you will not get an email!!!

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度