我尝试使用facebook auth登录登录 我可以访问用户所有数据,但用户电子邮件不显示
我在codeigniter控制器中使用了这段代码
include_once APPPATH."libraries/facebook-api-php-codexworld/facebook.php";
// Facebook API Configuration
$appId = '307082112994945';
$appSecret = '92ff6f98cc08c777c952fd79b1f1a396';
$redirectUrl = base_url() . 'auth-facebook/';
$fbPermissions = 'email';
//Call Facebook API
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $appSecret
));
$fbuser = $facebook->getUser();
if ($fbuser) {
$userProfile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,updated_time,picture');
// Preparing data for database insertion
$userData['oauth_provider'] = 'facebook';
$userData['oauth_uid'] = $userProfile['id'];
$userData['first_name'] = $userProfile['first_name'];
$userData['last_name'] = $userProfile['last_name'];
$userData['email'] = $userProfile['email'];
$userData['gender'] = $userProfile['gender'];
$userData['locale'] = $userProfile['locale'];
$userData['updated_time'] = $userProfile['updated_time'];
$userData['profile_url'] = 'https://www.facebook.com/'.$userProfile['id'];
$userData['picture_url'] = $userProfile['picture']['data']['url'];