<rt id="aqosi"><acronym id="aqosi"></acronym></rt>
<code id="aqosi"><delect id="aqosi"></delect></code>
<li id="aqosi"></li>
135用戶互聯(lián)


    1聯(lián)系135用戶互聯(lián)合作


    聯(lián)系135用戶互聯(lián)合作,獲得用戶互相的client_id, client_secret, 配置跳轉(zhuǎn)地址redirect_uri。

    2拼接135授權(quán)登錄鏈接


    授權(quán)登錄鏈接形如: http://www.135editor.com/oauth2/authorize?client_id=135plat&response_type=code&state=xyz&redirect_url=xxx

    參數(shù)說(shuō)明:

    client_id 為135為您分配的合作方標(biāo)識(shí)碼

    response_type參數(shù)使用固定值 code

    redirect_url 為配置好的授權(quán)后調(diào)整地址。

    state參數(shù)為任意值,會(huì)原樣返回

    3訪問(wèn)登錄鏈接進(jìn)入登錄頁(yè)面


    用戶點(diǎn)擊第二步拼接的授權(quán)登錄鏈接后,進(jìn)入授權(quán)登錄頁(yè),登錄并確認(rèn)授權(quán)后,跳轉(zhuǎn)到回調(diào)地址。

    跳轉(zhuǎn)地址中會(huì)增加兩個(gè)參數(shù),一個(gè)code,一個(gè)state


    3獲取access_token


    由于調(diào)用135編輯器會(huì)有跨域的問(wèn)題,在135地址完成編輯時(shí),會(huì)將結(jié)果提交到回調(diào)地址,通過(guò)回調(diào)地址調(diào)用最上層的內(nèi)容使用函數(shù)。設(shè)置內(nèi)容完成后,輸出iframe調(diào)用135編輯器的關(guān)閉頁(yè)面,關(guān)閉打開(kāi)的135窗口。

    注意:需要設(shè)置內(nèi)容輸出編碼為utf-8格式

    $result $this->post('http://www.135editor.com/oauth2/token', array( 
                
    'grant_type' => 'authorization_code'
                
    'code' => $_REQUEST['code'], 
                
    'client_id' => '135plat'
                
    'client_secret' => 'USpywDpmNNF25RGr',
            )); 

    $token json_decode($result,true); 

    /**返回結(jié)果**/

    Array
    (
        [access_token] => 7ea5a1a688b9ca6158f5fedc26085845e06aadc0
        [expires_in] => 3600
        [token_type] => Bearer
        [scope] => 
        [refresh_token] => f2a5b7313a1c213ebe0d13c3f1b2a7413c8d87ee
    )



    4獲取135用戶信息


    Get請(qǐng)求獲取用戶信息

    $result = $this->get_contents('http://test.wx135.com/oauth2/resource?access_token='.$token['access_token']);

    $userinfo = json_decode($result,true);

    通過(guò)用戶id作為135用戶唯一識(shí)別,與站點(diǎn)建立用戶對(duì)應(yīng)關(guān)系