Facebook登录/使用Codeigniter注册 - 用户数据 [英] Facebook Login/Registration with Codeigniter - user data

查看:175
本文介绍了Facebook登录/使用Codeigniter注册 - 用户数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用户数据有问题 - 我在Facebook登录后收到的唯一数据是'name'和'id',这是用户的Facebook ID。我还需要收到名字,姓氏和电子邮件。

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. I also need to recieve 'firstname', 'lastname' and 'email.

我在localhost测试网站,并在developers.facebook.com中创建了应用程序。

I'm testing the website at localhost and I've created app in 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();   

希望这也有助于回答您的问题。
Facebook官方文档

Hope this help too in answering your question. Facebook Official Documentation

您可以使用与用于显示这些数据的APP相同的Facebook ID登录,也可以使用Facebook工具,例如 https://developers.facebook.com/tools/explorer/ 查询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.

这篇关于Facebook登录/使用Codeigniter注册 - 用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆