PHP code example of asyncme / wechatdeveloper
1. Go to this page and download the library: Download asyncme/wechatdeveloper 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/ */
asyncme / wechatdeveloper example snippets
# 在项目中加载初始化文件
$config = [
'token' => 'xxx',
'appid' => 'xxx',
'appsecret' => 'xxxxx',
'encodingaeskey' => 'xxxx',
// 配置商户支付参数(可选,在使用支付功能时需要)
'mch_id' => "xxx",
'mch_key' => 'xxxx',
// 配置商户支付双向证书目录(可选,在使用退款|打款|红包时需要)
'ssl_key' => '',
'ssl_cer' => '',
//缓存配置
'cache_dirvers' => [
// redis配置
'driver'=>'redis',
'config'=>[
'host'=>'xxx',
'pass'=>'xxx',
'port'=>'xxx',
'db'=>'0',
]
/* file 配置
'driver'=>'file',
'config'=>[
'cache_path' => 'xxx',//(可选,需拥有读写权限)
'crypt'=>'md5',
],
*/
/*
'driver'=>'memcache',
'config'=>[
'host'=>'xxx',
'port'=>'xxx',
]
*/
/* 腾讯对象存储 cos,[未实现]
'driver'=>'cos',
'config'=>[
'region'=>'ap-guangzhou',
'credentials'=>[
'appId' => 'xxx',
'secretId' => 'xxx',
'secretKey' => 'xxx'
],
*/
]
];
try {
// 实例对应的接口对象
$user = new \WeChat\User($config);
// 调用接口对象方法
$list = $user->getUserList();
// 处理返回的结果
echo '<pre>';
var_export($list);
} catch (Exception $e) {
// 出错啦,处理下吧
echo $e->getMessage() . PHP_EOL;
}