Solution to codeigniter integration with ucenter1.6 bidirectional communication

Source: Internet
Author: User

Use codeigniter to develop a sub-website, and then want to synchronize with the original forum, including synchronous login and two-way communication

Install ucenter, create an other application, copy the generated code, and create a config. ini. php file to your uc_client. The ucenter generates a producer

Copy the uc_client to your website. You can set the directory by yourself. If you place the api directory in the uc_client directory, the application's Request Path is yourdomain.com/uc_client. if apiis also in the root directory, you can remove the request address uc_client.

Create a libraries/Ucenter. php file

Copy codeThe Code is as follows: <? 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 );
}
}
?>

For specific functions to be reversed, you can add them in the code above. You can open uc_client/client. php and add the functions you need to return them.

Call method:

Copy codeThe Code is as follows: $ 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 )){
// Generate the synchronous login code
$ Ucsynlogin = $ this-> ucenter-> synlogin ($ uid );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.