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

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://www.wsalc.com/2013/4-2/90130.html

關鍵詞:codeigniterucenter

贊助商鏈接:

主站蜘蛛池模板: 永靖县| 扎鲁特旗| 三明市| 峨眉山市| 扬州市| 涿州市| 盐边县| 左权县| 巨野县| 崇左市| 永靖县| 新龙县| 罗平县| 菏泽市| 中山市| 辛集市| 松江区| 迁安市| 安义县| 中西区| 垫江县| 长兴县| 汕尾市| 霍州市| 寿宁县| 山阳县| 沁源县| 隆回县| 大关县| 汪清县| 淅川县| 阳西县| 陆川县| 洪江市| 九龙坡区| 周口市| 长汀县| 额敏县| 宁武县| 罗源县| 育儿|