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