135用户互联


    1联系135用户互联合作


    联系135用户互联合作,获得用户互相的client_id, client_secret, 配置跳转地址redirect_uri。

    2拼接135授权登录链接


    授权登录链接形如: http://www.135editor.com/oauth2/authorize?client_id=135plat&response_type=code&state=xyz&redirect_url=xxx

    参数说明:

    client_id 为135为您分配的合作方标识码

    response_type参数使用固定值 code

    redirect_url 为配置好的授权后调整地址。

    state参数为任意值,会原样返回

    3访问登录链接进入登录页面


    用户点击第二步拼接的授权登录链接后,进入授权登录页,登录并确认授权后,跳转到回调地址。

    跳转地址中会增加两个参数,一个code,一个state


    3获取access_token


    由于调用135编辑器会有跨域的问题,在135地址完成编辑时,会将结果提交到回调地址,通过回调地址调用最上层的内容使用函数。设置内容完成后,输出iframe调用135编辑器的关闭页面,关闭打开的135窗口。

    注意:需要设置内容输出编码为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); 

    /**返回结果**/

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



    4获取135用户信息


    Get请求获取用户信息

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

    $userinfo = json_decode($result,true);

    通过用户id作为135用户唯一识别,与站点建立用户对应关系