UCenter 是國內Discuz公司開發的一個用戶管理中心,應該說現在是騰訊公司的。早年被騰訊收購。現在國內對于UCenter使用還是非常多的。只要是國內使用Discuz產品的,基本沒有不適用UCenter的。
今天研究了下,如何與UCenter實現通信,并且用戶同步.
首先下載UCenter安裝包 :去官網下載最新版本的包 http://www.comsenz.com/downloads/install/ucenter#down_open
解壓后會有4個文件夾
- advanced
- readme
- upload
- utilities
upload文件夾,顧名思義,需要我們上傳,其實這個就是用戶中心的安裝包。自己安裝吧。直接訪問首頁, 按照提示就能安裝了。這個很簡單,不用說。
然后訪問advanced文件夾,可以看到3個文件夾。我們需要的是uc_client 和examples目錄下的api文件夾,將uc_client和examples目錄下的api文件夾 拷貝至codeigniter 根目錄下.



填好需要填寫的信息后,
然后將滾動條拉到也蠻底部.
將 第三張圖片中,紅色框框里面的代碼復制到api目錄下的uc.php文件中.
然后將30行和79行的代碼替換成
<?php
if(!defined('IN_UC')) {
error_reporting(0);
set_magic_quotes_runtime(0);
defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
// require_once DISCUZ_ROOT.'./config.inc.php';
$_DCACHE = $get = $post = array();
$code = @$_GET['code'];
parse_str(_authcode($code, 'DECODE', UC_KEY), $get);
if(MAGIC_QUOTES_GPC) {
$get = _stripslashes($get);
}
$timestamp = time();
if($timestamp - $get['time'] > 3600) {
exit('Authracation has expiried');
}
if(empty($get)) {
exit('Invalid Request');
}
$action = $get['action'];
require_once DISCUZ_ROOT.'./uc_client/lib/xml.class.php';
$post = xml_unserialize(file_get_contents('php://input'));
if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {
$uc_note = new uc_note();
echo $uc_note->$get['action']($get, $post); exit();
} else {
exit(API_RETURN_FAILED);
}
//note include 通知方式 } else { exit(); }
?>

刷新下用戶中心的頁面.通信成功了~!
