简体   繁体   English

使用Codeigniter进行Facebook登录/注册-用户数据

[英]Facebook Login/Registration with Codeigniter - user data

I have a problem with the user data - the only data that I recieve after Facebook Login is 'name' and 'id', which is the facebook id of the user. 我的用户数据有问题-在Facebook登录后,我收到的唯一数据是“名称”和“ id”,即用户的Facebook ID。 I also need to recieve 'firstname', 'lastname' and 'email. 我还需要接收“名字”,“姓氏”和“电子邮件”。

I'm testing the website at localhost and I've created app in developers.facebook.com 我正在localhost上测试网站,并在developers.facebook.com中创建了应用程序

Maybe the problem is that the app is in developing mode and that's why it's not giving me the full data? 也许问题在于该应用程序处于开发模式,这就是为什么它没有提供全部数据的原因?

Here is my code of taking the user data: 这是我获取用户数据的代码:

<?php
include(APPPATH.'libraries/facebook/facebook.php');

class Fbconnect extends Facebook {

    public $user = null;
    public $user_id = null;
    public $fb = false;
    public $fbSession = false;
    public $appKey = 0;

    public function Fbconnect() {

        $ci =& get_instance();
        $ci->config->load('facebook', TRUE);
        $config = $ci->config->item('facebook');

        parent::__construct($config);

        $this->user_id = $this->getUser();
        $me = null;
        if($this->user_id) {
            try{
                $me = $this->api('/me');
                $this->user = $me;
            } catch(FacebookApiException $e) {
                error_log($e);
            }
        }
    }
} 
$my_profile_info = (new FacebookRequest($session, 'GET', '/me/?fields=id,first_name,last_name,email,picture,gender,location,address,email,hometown'))->execute()->getGraphObject()->asArray();   

Hope this help too in answering your question. 希望这也有助于回答您的问题。 Facebook Official Documentation Facebook官方文件

You could login using the same Facebook ID that you used for APP which will show these data, or you could use Facebook tools such as https://developers.facebook.com/tools/explorer/ to query facebook database. 您可以使用与用于显示这些数据的APP相同的Facebook ID登录,也可以使用诸如https://developers.facebook.com/tools/explorer/之类的 Facebook工具来查询facebook数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM