手机
当前位置:查字典教程网 >编程开发 >php教程 >codeigniter集成ucenter1.6双向通信的解决办法
codeigniter集成ucenter1.6双向通信的解决办法
摘要:用codeigniter开发一个子网站,之后想和原来的论坛进行同步,包括同步登陆和双向通信先装好ucenter,然后新建一个other的应用...

用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内容是

复制代码 代码如下:<?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);

}

【codeigniter集成ucenter1.6双向通信的解决办法】相关文章:

PHP实现即时输出、实时输出内容方法

php通过exif_read_data函数获取图片的exif信息

PHP准确取得服务器IP地址的方法

也谈 PHP 和 MYSQL

PHP输出缓冲控制Output Control系列函数详解

php快速查找数据库中恶意代码的方法

php计算整个目录大小的方法

Content-type 的说明

聊天室php&mysql(二)

PHP如何透过ODBC来存取数据库

精品推荐
分类导航