Home php教程 php手册 codeigniter集成ucenter1.6双向通信的解决办法

codeigniter集成ucenter1.6双向通信的解决办法

Jun 06, 2016 pm 08:21 PM
codeigniter

用codeigniter开发一个子网站,之后想和原来的论坛进行同步,包括同步登陆和双向通信。这篇文章主要介绍了codeigniter集成ucenter1.6双向通信的解决办法,需要的

用codeigniter开发一个子网站,之后想和原来的论坛进行同步,包括同步登陆和双向通信

先装好ucenter,然后新建一个other的应用,把生成的代码拷出来,新建一个config.ini.php到你的uc_client,ucenter会产生一个yourdomain.com/api/uc.php的请求,/api/uc.php不需要填写,要保证ucenter请求正确位置,才能做到双向通信

把uc_client复制到你的网站,目录可以自己定,就根目录吧。如果你把api目录放到uc_client目录低下,那么应用的请求路径yourdomain.com/uc_client,如果api也放在根目录请求地址uc_client可以去掉

建一个libraries/Ucenter.php内容是

复制代码 代码如下:

class Ucenter {
    function __construct() {
        require_once FCPATH . './api/uc_client/config.inc.php';
        require_once FCPATH . './api/uc_client/client.php';
    }

    function getUserId() {
        return $this->_uid;
    }

    function getUserName() {
        return ucwords(strtolower($this->_username));
    }

    function login($username, $password) {
        return uc_user_login($username, $password);
    }
    function synlogin($uid) {
        return uc_user_synlogin($uid);
    }

    function login_out() {
        return uc_user_synlogout();
    }

    function regediter($username, $password, $email) {
        return uc_user_register($username, $password, $email);
    }
}
?>

具体要反回哪些函数,可以在上面代码加上,可以打开uc_client/client.php看,可以加上你需要的函数,,返回即可。

调用方法:

复制代码 代码如下:

$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->library('ucenter');
list($uid, $username, $password, $email) = $this->ucenter->login($username, $password);
if(!empty($uid)){
    //生成同步登录的代码
    $ucsynlogin = $this->ucenter->synlogin($uid);
}

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement custom middleware in CodeIgniter How to implement custom middleware in CodeIgniter Jul 29, 2023 am 10:53 AM

How to implement custom middleware in CodeIgniter

CodeIgniter middleware: Accelerate application responsiveness and page rendering CodeIgniter middleware: Accelerate application responsiveness and page rendering Jul 28, 2023 pm 06:51 PM

CodeIgniter middleware: Accelerate application responsiveness and page rendering

PHP development: Using CodeIgniter to implement MVC pattern and RESTful API PHP development: Using CodeIgniter to implement MVC pattern and RESTful API Jun 16, 2023 am 08:09 AM

PHP development: Using CodeIgniter to implement MVC pattern and RESTful API

How to use the database query builder (Query Builder) in the CodeIgniter framework How to use the database query builder (Query Builder) in the CodeIgniter framework Jul 28, 2023 pm 11:13 PM

How to use the database query builder (Query Builder) in the CodeIgniter framework

How to use CodeIgniter5 framework in php? How to use CodeIgniter5 framework in php? Jun 01, 2023 am 11:21 AM

How to use CodeIgniter5 framework in php?

CodeIgniter middleware: Provides secure file upload and download functions CodeIgniter middleware: Provides secure file upload and download functions Aug 01, 2023 pm 03:01 PM

CodeIgniter middleware: Provides secure file upload and download functions

How to use the PHP framework CodeIgniter to quickly build a backend management system How to use the PHP framework CodeIgniter to quickly build a backend management system Jun 27, 2023 am 09:46 AM

How to use the PHP framework CodeIgniter to quickly build a backend management system

Use PHP framework CodeIgniter to develop a real-time chat application to provide convenient communication services Use PHP framework CodeIgniter to develop a real-time chat application to provide convenient communication services Jun 27, 2023 pm 02:49 PM

Use PHP framework CodeIgniter to develop a real-time chat application to provide convenient communication services

See all articles