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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
