Ucenter整合Discuz同步登錄
- 1、先安裝UCenter 再安裝Discuz
- 2、登錄Discuz,用戶名:admin, 密碼:admin
- 3、登錄Discuz后臺管理 密碼:admin
- 4、登錄UCenter ,選擇應用。會有一個已通信成功的UCenter+Discuz應用
或:在安裝Discuz之后,會有一個UCenter,并且已建立好一個應用,可以用這個,日前未試過同步登錄是否可行。
Codeigniter整合Ucenter同步登錄
說明:本地測試服務器配置開啟URL重寫
1、在康盛網站http://www.comsenz.com/downloads/install/ucenter下載ucenter源碼包
2、解壓后,將uc_client文件夾復制到CI根目錄。同樣,在advanced/examples復制api文件夾、include文件夾、config.inc.php到CI根目錄。
3、在UCENTER管理中心添加一個應用,
- 應用類型:其他
- 應用名稱:CI
- 應用的主URL:【要建立連接的網站網址】如:http://www.aaa.com
- 應用IP:127.0.0.1
- 通信密鑰:到config.inc.php找‘UC_KEY’字段的值。
- 選擇“開啟同步、接受通知”。
- 得到應用id,寫入config.inc.php文件中‘UC_APPID’字段。
4、在CI根目錄找到config.inc.php修改相應的數據庫配置。
5、配置好之后還是顯示通信失敗,是因為CI啟用了URL重寫,需要配置CI根目錄下的.htaccess文件,添加uc_client、api、include到被忽略的列表,如下:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|ckeditor|ckfinder|uploadfile|robots\.txt|uc_client|config\.inc\.php|api|include)
RewriteRule ^(.*)$ index.php/$1 [L]
6、在到ucenter管理中心可以看到通信成功!
7、在CI建立自己的類庫,如在application/ libraries下新建一個文件Mycommon.php
<?php
class Mycommon {
function __construct(){
include './config.inc.php';
include './uc_client/client.php';
}
function getUserId() {
return $this->_uid;
}
function getUserName() {
return ucwords ( strtolower ( $this->_username ) );
}
function login($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);
}
}
?>
8、接下來就可以在控制器中調用
$this->load->library(‘mycommon’);
echo $this->mycommon->login(id);