littlemo / wechat
the littlemo wechat tools
Installs: 88
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.0
- littlemo/utils: *
- wechatpay/wechatpay: *
This package is auto-updated.
Last update: 2024-11-11 03:31:16 UTC
README
介绍
微信常用工具库
安装
composer.json
{ "require": { "littlemo/wechat": "1.8.*" } }
composer require littlemo/wechat:"1.8.*"
使用
公共
公共部分被所有方法继承,实例化任意类均可调用
use littlemo\wechat\Class; $Class = new Class($appid , $secret, $mchid , $key , $certPath, $keyPath );
实例化参数
token
获取全局Access token(支持:公众号、小程序)
示例代码
use littlemo\wechat\Class; use littlemo\wechat\core\LWechatException; $Class = new Class($appid, $appkey); $result = $Class->token(); if ($result) { echo '获取Access token成功'; $token = $Class->getMessage(); } else { echo "获取Access token失败"; $errorMsg = $Class->getErrorMsg(); } try{ $data = $Class->token() }catch(LWechatException $e){ print_r('错误代码:'.$e->getCode()); print_r('错误提示:'.$e->getMessage()); print_r('完整的内容:'.json_encode($e->getData())); }; //查询完整的回调消息 $intactMsg = $Class->getIntactMsg();
返回示例
{ "access_token":"ACCESS_TOKEN", "expires_in":7200 }
公众号
小程序
整理中...
开放平台
整理中...
微信支付
整理中...
参与贡献
- littlemo
特技
- 统一、精简