成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

codeigniter集成ucenter 1.6雙向通信的技巧

2013-04-02 17:15:39來源:afen和IT那點事兒作者:afen

用codeigniter開發一個子網站,之后想和原來的論壇進行同步,包括同步登陸和雙向通信

用codeigniter開發一個子網站,之后想和原來的論壇進行同步,包括同步登陸和雙向通信

先裝好ucenter,然后新建一個other的應用,把生成的代碼拷出來,新建一個config.ini.php到你的uc_client,ucenter會產生一個yourdomain.com/api/uc.php的請求,/api/uc.php不需要填寫,要保證ucenter請求正確位置,才能做到雙向通信

把uc_client復制到你的網站,目錄可以自己定,就根目錄吧。如果你把api目錄放到uc_client目錄低下,那么應用的請求路徑yourdomain.com/uc_client,如果api也放在根目錄請求地址uc_client可以去掉

建一個libraries/Ucenter.php內容是

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

具體要反回哪些函數,可以在上面代碼加上,可以打開uc_client/client.php看,可以加上你需要的函數,返回即可。

調用方法:

$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)){
    //生成同步登錄的代碼
    $ucsynlogin = $this->ucenter->synlogin($uid);
}

如果雙向通信有問題可以查看:http://m.wsalc.com/2013/4-2/90130.html

關鍵詞:codeigniterucenter

贊助商鏈接:

主站蜘蛛池模板: 左贡县| 绩溪县| 宝坻区| 保靖县| 新民市| 遂溪县| 梅州市| 纳雍县| 昌都县| 长泰县| 方城县| 镇宁| 始兴县| 修文县| 泌阳县| 富宁县| 调兵山市| 长兴县| 榕江县| 甘孜| 十堰市| 锦州市| 贺州市| 获嘉县| 昆山市| 抚远县| 麻阳| 英山县| 东阳市| 凤凰县| 昌黎县| 罗江县| 永和县| 安顺市| 罗甸县| 香格里拉县| 太谷县| 通海县| 新巴尔虎左旗| 定西市| 天等县|