PHP code example of littlemo / qq

1. Go to this page and download the library: Download littlemo/qq library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

littlemo / qq example snippets


use littlemo\qq\OAuth2;

$OAuth2 = new OAuth2($appid, $appkey);

//使用Authorization_Code获取Access_Token
$result = $OAuth2->token($Authorization_Code, $redirect_uri);
if ($result) {
    echo '获取Access_Token成功';
    $token = $OAuth2->getMessage();
} else {
    echo "获取Access_Token失败";
    $errorMsg = $OAuth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $OAuth2->getIntactMsg();



use littlemo\qq\OAuth2;

$OAuth2 = new OAuth2($appid, $appkey);

$result = $OAuth2->refresh_token($refresh_token)

if ($result) {
    echo '刷新Access_Token成功';
    $token = $OAuth2->getMessage();
} else {
    echo "刷新Access_Token失败";
    $errorMsg = $OAuth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $OAuth2->getIntactMsg();



use littlemo\qq\OAuth2;

$OAuth2 = new OAuth2($appid, $appkey);

$result = $OAuth2->me($access_token)

if ($result) {
    echo '获取OpenID成功';
    $token = $OAuth2->getMessage();
} else {
    echo "获取OpenID失败";
    $errorMsg = $OAuth2->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $OAuth2->getIntactMsg();



use littlemo\qq\User;

$User = new User($appid, $appkey);

$result = $User->get_user_info($access_token, $openid)

if ($result) {
    echo '获取用户信息成功';
    $token = $User->getMessage();
} else {
    echo "获取用户信息失败";
    $errorMsg = $User->getErrorMsg();
}

//查询完整的回调消息
$intactMsg = $OAuth2->getIntactMsg();