littlemo/wechat

the littlemo wechat tools

v1.8.2 2024-10-11 03:19 UTC

README

Total Downloads Latest Stable Version Latest Unstable Version PHP Version License

介绍

微信常用工具库

安装

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
}

官方文档

公众号

小程序

整理中...

开放平台

整理中...

微信支付

整理中...

参与贡献

  1. littlemo

特技

  • 统一、精简