PHP code example of hcg / test

1. Go to this page and download the library: Download hcg/test 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/ */

    

hcg / test example snippets




��相关配置
$app_id = '';
$app_secret = '';
$config = new Hcg\Wechat\Config($app_id, $app_secret);
$access_token = new Hcg\Wechat\AccessToken($config);

// 获取access_token(从redis缓存中获取access_token)
echo $access_token->getAccessToken();

// 输出换行,方便命令行中查看
echo "\r\n";

// 强制更新access_token,这里会输出access_token
echo $access_token->forceUpdate()->getAccessToken();



��相关配置
$app_id = '';
$app_secret = '';
$config = new Hcg\Wechat\Config($app_id, $app_secret);
$access_token = new Hcg\Wechat\AccessToken($config);

$post_data = [
    'path' => 'pages/home/home',
    // 二维码的宽度,单位 px。最小 280px,最大 1280px
    'width' => '430',
];
$qrcode = new Hcg\Wechat\Mini\QRCode($access_token);
// 这里会输出小程序二维码的本地图片路径
echo $qrcode->getWxaCode($post_data);