Ucenter整合Discuz同步登錄php
一、先安裝UCenter 再安裝Discuz
二、登陸Discuz,用戶名:admin, 密碼:admin
三、登陸Discuz後臺管理 密碼:admin
四、登陸UCenter ,選擇應用。會有一個已通訊成功的UCenter+Discuz應用數據庫
或:在安裝Discuz以後,會有一個UCenter,而且已創建好一個應用,能夠用這個,日前未試過同步登陸是否可行。api
Codeigniter整合Ucenter同步登錄
說明:本地測試服務器配置開啓URL重寫
一、在康盛網站http://www.comsenz.com/downloads/install/ucenter下載ucenter源碼包
二、解壓後,將uc_client文件夾複製到CI根目錄。一樣,在advanced/examples複製api文件夾、include文件夾、config.inc.php到CI根目錄。
三、在UCENTER管理中心添加一個應用,
應用類型:其餘
應用名稱:CI、
應用的主URL:【要創建鏈接的網站網址】如:http://www.what.com、
應用IP:127.0.0.1
通訊密鑰:到config.inc.php找‘UC_KEY’字段的值。
選擇「開啓同步、接受通知」。
獲得應用id,寫入config.inc.php文件中‘UC_APPID’字段。
四、在CI根目錄找到config.inc.php修改相應的數據庫配置。
五、配置好以後仍是顯示通訊失敗,是由於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]
六、在到ucenter管理中心能夠看到通訊成功!
七、在CI創建本身的類庫,如在application/ libraries下新建一個文件Mycommon.phpapp
<?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); } } ?>
八、接下來就能夠在控制器中調用測試
$this->load->library(‘mycommon’); echo $this->mycommon->login(id);