Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-06 20:21:46
Original
1434 people have browsed it

用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);
}

Related labels:
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template