Skip to content

示例

👏🏻 欢迎点击本页下方 "帮助我们改善此页面!" 链接参与贡献更多的使用示例!

生成小程序码(wxacode.getUnlimited)

官方文档:wxacode.getUnlimited

try {
    $response = $app->getClient()->postJson('/wxa/getwxacodeunlimit', [
        'scene' => '123',
        'page' => 'pages/index/index',
        'width' => 430,
        'check_path' => false,
    ]);
    
    $path = $response->saveAs('/tmp/wxacode-123.png');
} catch (\Throwable $e) {
    // 失败
    echo $e->getMessage();
}
获取手机号(phonenumber.getPhoneNumber)

官方文档:phonenumber.getPhoneNumber

// routes/api.php
use EasyWeChat\MiniApp\Application;
Route::post('getPhoneNumber', function () {
    // $app 实例化步骤这里省略 
    $data = [
      'code' => (string) request()->get('code'),
    ];

    return $app->getClient()->postJson('wxa/business/getuserphonenumber', $data);
  }
}

Released under the MIT License.