PHP code example of yandy / wechat-xiaowei
1. Go to this page and download the library: Download yandy/wechat-xiaowei 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/ */
yandy / wechat-xiaowei example snippets
use wei/Wechat;
$config = [
'appid' => 'wx123456',
'secret' => '6b9bb37515ebd8f7d08c6329c5f5555',
'mch_id' => '1245668921', //商户号
'serial_no' => '67E04C9243E70B7C38F371E4EB4907F10B171B45', //商户证书序列号
'aes_key' => 'abc1abc2abc3abc4abc5abc6abc7abc8',
'diy_key' => 'abc1abc2abc3abc4abc5abc6abc7abc8', //自定义key
];
$wecaht = new Wechat($config);
try {
$wechat->downloadCertificates(); //下载证书
echo "成功";
} catch (WxException $e) {
echo $e->getMessage();
} catch (\Exception $e) {
echo $e->getMessage();
}