codeigniter集積ucenter 1.6双方向通信の解決方法

1917 ワード

codeigniterでサブサイトを開発し、同期ログインや双方向通信など、元のフォーラムと同期したい
ucenterをインストールしてからotherのアプリケーションを新規作成し、生成したコードをコピーしてconfigを新規作成します.ini.phpからucへクライアント、ucenterはyourdomainを生成します.com/api/uc.phpのリクエスト、/api/uc.phpは記入する必要はありません.ucenterが正しい位置を要求することを保証しなければ、双方向通信ができません.
uc_をClientはあなたのサイトにコピーして、ディレクトリは自分で決めることができて、ルートディレクトリにしましょう.apiディレクトリをuc_に置くとクライアントディレクトリが低いと、アプリケーションのリクエストパスが表示されます.com/uc_Client、apiもルートディレクトリリクエストアドレスuc_に置くとクライアントは削除できます
libraries/Ucenterを作ろう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);
}