codeigniter集成ucenter1.6雙向通信的解決辦法
用codeigniter開(kāi)發(fā)一個(gè)子網(wǎng)站,之后想和原來(lái)的論壇進(jìn)行同步,包括同步登陸和雙向通信
先裝好ucenter,然后新建一個(gè)other的應(yīng)用,把生成的代碼拷出來(lái),新建一個(gè)config.ini.php到你的uc_client,ucenter會(huì)產(chǎn)生一個(gè)yourdomain.com/api/uc.php的請(qǐng)求,/api/uc.php不需要填寫,要保證ucenter請(qǐng)求正確位置,才能做到雙向通信
把uc_client復(fù)制到你的網(wǎng)站,目錄可以自己定,就根目錄吧。如果你把a(bǔ)pi目錄放到uc_client目錄低下,那么應(yīng)用的請(qǐng)求路徑y(tǒng)ourdomain.com/uc_client,如果api也放在根目錄請(qǐng)求地址uc_client可以去掉
建一個(gè)libraries/Ucenter.php內(nèi)容是
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);
}
}
?>
具體要反回哪些函數(shù),可以在上面代碼加上,可以打開(kāi)uc_client/client.php看,可以加上你需要的函數(shù),返回即可。
調(diào)用方法:
$password = $this->input->post('password');
$this->load->library('ucenter');
list($uid, $username, $password, $email) = $this->ucenter->login($username, $password);
if(!empty($uid)){
//生成同步登錄的代碼
$ucsynlogin = $this->ucenter->synlogin($uid);
}
- CodeIgniter集成smarty的方法詳解
- Codeigniter中集成smarty和adodb的方法
- CodeIgniter中使用Smarty3基本配置
- 讓codeigniter與swfupload整合的最佳解決方案
- Codeigniter整合Tank Auth權(quán)限類庫(kù)詳解
- CI(CodeIgniter)框架中的增刪改查操作
- CodeIgniter啟用緩存和清除緩存的方法
- Codeigniter(CI)框架分頁(yè)函數(shù)及相關(guān)知識(shí)
- CI(CodeIgniter)框架配置
- CodeIgniter輔助函數(shù)helper詳解
- php之CodeIgniter學(xué)習(xí)筆記
- CodeIgniter整合Smarty的方法詳解
相關(guān)文章
創(chuàng)建數(shù)據(jù)庫(kù)php代碼 用PHP寫出自己的BLOG系統(tǒng)
今天的任務(wù)是創(chuàng)建數(shù)據(jù)庫(kù),因?yàn)閷?duì)數(shù)據(jù)庫(kù)懂的很少,所以在數(shù)據(jù)庫(kù)表關(guān)系上還很差啊。2010-04-04
通過(guò)PHP的Wrapper無(wú)縫遷移原有項(xiàng)目到新服務(wù)的實(shí)現(xiàn)方法
這篇文章主要介紹了通過(guò)PHP的Wrapper無(wú)縫遷移原有項(xiàng)目到新服務(wù)的實(shí)現(xiàn)方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04
Yii實(shí)現(xiàn)的多級(jí)聯(lián)動(dòng)下拉菜單
這篇文章主要介紹了Yii實(shí)現(xiàn)的多級(jí)聯(lián)動(dòng)下拉菜單,包括視圖、模型及控制器的相關(guān)實(shí)現(xiàn)代碼,涉及基于Yii的數(shù)據(jù)庫(kù)查詢、數(shù)組遍歷與數(shù)據(jù)顯示等相關(guān)操作技巧,需要的朋友可以參考下2016-07-07
PHP+swoole實(shí)現(xiàn)簡(jiǎn)單多人在線聊天群發(fā)
這篇文章主要介紹了PHP+swoole實(shí)現(xiàn)簡(jiǎn)單多人在線聊天群發(fā) 的相關(guān)資料,需要的朋友可以參考下2016-01-01
PHP設(shè)計(jì)模式之迭代器(Iterator)模式入門與應(yīng)用詳解
這篇文章主要介紹了PHP設(shè)計(jì)模式之迭代器(Iterator)模式,結(jié)合實(shí)例形式詳細(xì)分析了PHP迭代器模式的相關(guān)概念、原理、應(yīng)用案例及操作注意事項(xiàng),需要的朋友可以參考下2019-12-12

