PHP code example of quansitech / qs-easywechat

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

    

quansitech / qs-easywechat example snippets


use Qs\EasyWechat\MiniProgram;

$mp = new MiniProgram();

/*
 * 该方式必须在.env文件定义
 * MINI_APPID
 * MINI_APPSECRET
 * MINI_MSG_TOKEN
 * MINI_MSG_AESKEY
 */

use Qs\EasyWechat\MiniProgram;
$config = [
    'app_id' => '****',
    'secret' => '****',
    'token' => '****',
    'aes_key' => '****',

    'log' => [
        'level' => 'debug',
        'file' => __DIR__.'/wechat.log',
    ],

    'response_type' => 'array'
];
$mp = new MiniProgram($config);

> use Qs\EasyWechat\MiniProgram;
> 
> $mp = new MiniProgram();
> $res = $mp->app->phone_number->getUserPhoneNumber($code);
> echo $res['phone_info']['purePhoneNumber'];
>  

> use Qs\EasyWechat\MiniProgram;
> 
> $mp = new MiniProgram();
> $img_data = file_get_contents(WWW_DIR . '/idcard.png');
> $res = $mp->app->id_card_ocr->scanByImg(base64_encode($img_data));
> 
> $mp->app->id_card_ocr->scanByImgUrl("http://test.com/idcard.png");
>