20 Star 36 Fork 11

youwen21 / exwechat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

exwechat是一个微信公众号开发包

重要组成

  • Config 微信公众号配置管理
  • Cache 实现Psr\SimpleCache\CacheInterface PSR协议的缓存包
  • TokenManager 依赖Config和Cache, 从微信api获得access_token,缓存它。
  • ApiClient, 包装GuzzleHttp/Client
  • requests, 每一个request都对应微信公众号的API

TokenManager 和 ApiClient是最重要的两个类。
TokenManager 调度cache缓存access_token。 另外从微信公众号获得access_token。
ApiClient 包装GuzzleHttp/Client, xmlProcessor, jsonProcessor三个类。 一部分调用微信公众号接口,另一部分是处理response返回的xml和json内容为array数组。

如何记录接口请求日志

guzzle http middleware 可以设置中间件,通过中间件记录日志
推荐:

https://github.com/gmponos/guzzle-log-middleware

https://github.com/namshi/cuzzle

已集成的api接口列表

下列表写(否)的接口代码不是微信提供的api接口,而是微信请求我方服务器接口。需要我方根据自身业务进行开发。

需自行开发功能列表

- 微信卡券
- 微信门店
- 微信小店
- 智能接口
- 微信设备功能
- 新版客服功能
- 对话能力(原导购助手)
- 微信“一物一码”
- 微信发票
- 微信非税缴费

DEMO1

$redis = RedisFactory::create();
$redisCache = new RedisCache($redis);
$config = [
    'app_id' => '',
    'secret' => '',
    'redirect_uri' => '',
];

$tokenManager = new TokenManager($config, $redisCache);
$token = $tokenManager->getAccessToken();
$api = new ApiClient();

$ipRequest = (new Ips)->getIps($token);
$response = $api->send($ipRequest);

DEMO2 使用facade

// facade
$redis = RedisFactory::create();
$redisCache = new RedisCache($redis);
$config = [
    'app_id' => '',
    'secret' => '',
    'redirect_uri' => '',
];

$tokenManager = new TokenManager($config, $redisCache);
$token = $tokenManager->getAccessToken();
$api = new ApiClient();

$facade = new WechatFacade($tokenManager, $api);

$ips = $facade->getIps();
MIT License Copyright (c) 2021 youwen21 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

PHP开发的微信公众号扩展库 - 微信菜单,消息回复,多媒体图片音乐,OAuth,JSSDK等 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/youwen21/exwechat.git
git@gitee.com:youwen21/exwechat.git
youwen21
exwechat
exwechat
master

搜索帮助