mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-10-03 05:49:59 +08:00
Compare commits
No commits in common. "master" and "v1.1.17" have entirely different histories.
65
.github/workflows/release.yml
vendored
65
.github/workflows/release.yml
vendored
@ -1,65 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
name: Create Release
|
||||
permissions: write-all
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install -g gen-git-log
|
||||
|
||||
- name: Find Last Tag
|
||||
id: last_tag
|
||||
run: |
|
||||
|
||||
# 获取所有标签,按版本排序(降序)
|
||||
Tags=$(git tag --list --sort=-version:refname)
|
||||
|
||||
# 获取最新的标签(即列表中的第一个)
|
||||
LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}')
|
||||
|
||||
# 获取倒数第二个标签(如果存在)
|
||||
if [[ -n "$Tags" ]]; then
|
||||
# 使用 tail 获取除了最后一个标签之外的所有标签,然后用 head 获取第一个
|
||||
SECOND_LATEST_TAG=$(echo "$Tags" | tail -n +2 | head -n 1)
|
||||
else
|
||||
SECOND_LATEST_TAG=""
|
||||
fi
|
||||
|
||||
# 设置输出变量
|
||||
echo "::set-output name=tag_last::${LATEST_TAG:-v1.0.0}"
|
||||
echo "::set-output name=tag_second::${SECOND_LATEST_TAG:-v1.0.0}"
|
||||
|
||||
- name: Generate Release Notes
|
||||
run: |
|
||||
rm -rf log
|
||||
newTag=${{ steps.last_tag.outputs.tag_last }}
|
||||
git-log -m tag -f -S ${{ steps.last_tag.outputs.tag_second }} -v ${newTag#v}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.last_tag.outputs.tag_last }}
|
||||
release_name: Release ${{ steps.last_tag.outputs.tag_last }}
|
||||
body_path: log/${{steps.last_tag.outputs.tag_last}}.md
|
||||
draft: false
|
||||
prerelease: false
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,4 @@
|
||||
/vendor
|
||||
/Cache
|
||||
/Test/cert
|
||||
/nbproject
|
||||
/composer.lock
|
||||
/_test/cert
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝App支付网关
|
||||
* Class App
|
||||
* @package AliPay
|
||||
*/
|
||||
class App extends BasicAliPay
|
||||
{
|
||||
|
||||
/**
|
||||
* App constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.trade.app.pay');
|
||||
$this->params->set('product_code', 'QUICK_MSECURITY_PAY');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
$this->applyData($options);
|
||||
return http_build_query($this->options->get());
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝电子面单下载
|
||||
* Class Bill
|
||||
* @package AliPay
|
||||
*/
|
||||
class Bill extends BasicAliPay
|
||||
{
|
||||
/**
|
||||
* Bill constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.data.dataservice.bill.downloadurl.query');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
return $this->getResult($options);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝刷卡支付
|
||||
* Class Pos
|
||||
* @package AliPay
|
||||
*/
|
||||
class Pos extends BasicAliPay
|
||||
{
|
||||
/**
|
||||
* Pos constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.trade.pay');
|
||||
$this->params->set('product_code', 'FACE_TO_FACE_PAYMENT');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
return $this->getResult($options);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝扫码支付
|
||||
* Class Scan
|
||||
* @package AliPay
|
||||
*/
|
||||
class Scan extends BasicAliPay
|
||||
{
|
||||
/**
|
||||
* Scan constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.trade.precreate');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
return $this->getResult($options);
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝标准接口
|
||||
* Class Trade
|
||||
* @package AliPay
|
||||
*/
|
||||
class Trade extends BasicAliPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置交易接口地址
|
||||
* @param string $method
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->options->set('method', $method);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交易接口地址
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->options->get('method');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置接口公共参数
|
||||
* @param array $option
|
||||
* @return Trade
|
||||
*/
|
||||
public function setOption($option = [])
|
||||
{
|
||||
foreach ($option as $key => $vo) {
|
||||
$this->options->set($key, $vo);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口公共参数
|
||||
* @return array|string|null
|
||||
*/
|
||||
public function getOption()
|
||||
{
|
||||
return $this->options->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行通过接口
|
||||
* @param array $options
|
||||
* @return array|boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
return $this->getResult($options);
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝转账到账户
|
||||
* Class Transfer
|
||||
* @package AliPay
|
||||
*/
|
||||
class Transfer extends BasicAliPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 旧版 向指定支付宝账户转账
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
$this->options->set('method', 'alipay.fund.trans.toaccount.transfer');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 向指定支付宝账户转账
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create($options = [])
|
||||
{
|
||||
$this->options->set('method', 'alipay.fund.trans.uni.transfer');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 转账业务单据查询接口
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryResult($options = [])
|
||||
{
|
||||
$this->options->set('method', 'alipay.fund.trans.common.query');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 支付宝资金账户资产查询接口
|
||||
* @param array $options
|
||||
* @return array|bool
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryAccount($options = [])
|
||||
{
|
||||
$this->options->set('method', 'alipay.fund.account.query');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 手机WAP网站支付支持
|
||||
* Class Wap
|
||||
* @package AliPay
|
||||
*/
|
||||
class Wap extends BasicAliPay
|
||||
{
|
||||
/**
|
||||
* Wap constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.trade.wap.pay');
|
||||
$this->params->set('product_code', 'QUICK_WAP_WAY');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
parent::applyData($options);
|
||||
return $this->buildPayHtml();
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace AliPay;
|
||||
|
||||
use WeChat\Contracts\BasicAliPay;
|
||||
|
||||
/**
|
||||
* 支付宝网站支付
|
||||
* Class Web
|
||||
* @package AliPay
|
||||
*/
|
||||
class Web extends BasicAliPay
|
||||
{
|
||||
/**
|
||||
* Web constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options)
|
||||
{
|
||||
parent::__construct($options);
|
||||
$this->options->set('method', 'alipay.trade.page.pay');
|
||||
$this->params->set('product_code', 'FAST_INSTANT_TRADE_PAY');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据操作
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function apply($options)
|
||||
{
|
||||
parent::applyData($options);
|
||||
return $this->buildPayHtml();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2014-2023 Anyon <zoujingli@qq.com>
|
||||
Copyright (c) 2014-2018 Anyon<zoujingli@qq.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
174
README.md
Normal file
174
README.md
Normal file
@ -0,0 +1,174 @@
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
|
||||
WeChatDeveloper for PHP
|
||||
--
|
||||
* WeChatDeveloper 是基于 [wechat-php-sdk](https://github.com/zoujingli/wechat-php-sdk) 重构,优化并完善;
|
||||
* 运行最底要求 PHP 版本 5.4 , 建议在 PHP7 上运行以获取最佳性能;
|
||||
* WeChatDeveloper 针对 access_token 失效增加了自动刷新机制;
|
||||
* 微信的部分接口需要缓存数据在本地,因此对目录需要有写权限;
|
||||
* 我们鼓励大家使用 composer 来管理您的第三方库,方便后期更新操作;
|
||||
* WeChatDeveloper 已历经数个线上项目考验,欢迎 fork 或 star 此项目。
|
||||
|
||||
|
||||
Documentation
|
||||
--
|
||||
PHP开发技术交流(QQ群 513350915)
|
||||
|
||||
[](http://shang.qq.com/wpa/qunwpa?idkey=ae25cf789dafbef62e50a980ffc31242f150bc61a61164458216dd98c411832a)
|
||||
|
||||
WeChatDeveloper 是基于官方接口封装,在做微信开发前,必需先阅读微信官方文档。
|
||||
* 微信官方文档:https://mp.weixin.qq.com/wiki
|
||||
* 商户支付文档:https://pay.weixin.qq.com/wiki/doc/api/index.html
|
||||
|
||||
针对 WeChatDeveloper 也有一准备了帮助资料可供参考。
|
||||
* ThinkAdmin:https://github.com/zoujingli/Think.Admin
|
||||
* 开发文档地址:https://www.kancloud.cn/zoujingli/wechat-developer
|
||||
|
||||
|
||||
Repositorie
|
||||
--
|
||||
WeChatDeveloper 为开源项目,允许把它用于任何地方,不受任何约束,欢迎 fork 项目。
|
||||
* Gitee 托管地址:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
* GitHub 托管地址:https://github.com/zoujingli/WeChatDeveloper
|
||||
|
||||
ClassMap
|
||||
--
|
||||
|
||||
|
||||
|文件名|类名|描述|类型|加载 ①|
|
||||
|---|---|---|---|---|
|
||||
| Card.php | WeChat\Card | 微信卡券接口支持 | 认证服务号 | \We::WeChatCard() |
|
||||
| Custom.php | WeChat\Custom | 微信客服消息接口支持 | 认证服务号 | \We::WeChatCustom() |
|
||||
| Media.php | WeChat\Media | 微信媒体素材接口支持 | 认证服务号 | \We::WeChatMedia() |
|
||||
| Oauth.php | WeChat\Oauth | 微信网页授权消息类接口 | 认证服务号 | \We::WeChatOauth() |
|
||||
| Pay.php | WeChat\Pay | 微信支付类接口 | 认证服务号 | \We::WeChatPay() |
|
||||
| Product.php | WeChat\Product | 微信商店类接口 | 认证服务号 | \We::WeChatProduct() |
|
||||
| Qrcode.php | WeChat\Qrcode | 微信二维码接口支持 | 认证服务号 | \We::WeChatQrcode() |
|
||||
| Receive.php | WeChat\Receive | 微信推送事件消息处理支持 | 认证服务号 | \We::WeChatReceive() |
|
||||
| Scan.php | WeChat\Scan | 微信扫一扫接口支持 | 认证服务号 | \We::WeChatScan() |
|
||||
| Script.php | WeChat\Script | 微信前端JSSDK支持 | 认证服务号 | \We::WeChatScript() |
|
||||
| Shake.php | WeChat\Shake | 微信蓝牙设备揺一揺接口 | 认证服务号 | \We::WeChatShake() |
|
||||
| Tags.php | WeChat\Tags | 微信粉丝标签接口支持 | 认证服务号 | \We::WeChatTags() |
|
||||
| Template.php | WeChat\Template | 微信模板消息接口支持 | 认证服务号 | \We::WeChatTemplate() |
|
||||
| User.php | WeChat\User | 微信粉丝管理接口支持 | 认证服务号 | \We::WeChatCard() |
|
||||
| Wifi.php | WeChat\Wifi | 微信门店WIFI管理支持 | 认证服务号 | \We::WeChatWifi() |
|
||||
| Bill.php | WePay\Bill | 微信商户账单及评论 | 微信支付 | \We::WePayBill() |
|
||||
| Coupon.php | WePay\Coupon | 微信商户代金券 | 微信支付 | \We::WePayCoupon() |
|
||||
| Order.php | WePay\Order | 微信商户订单 | 微信支付 | \We::WePayOrder() |
|
||||
| Redpack.php | WePay\Redpack | 微信红包支持 | 微信支付 | \We::WePayRedpack() |
|
||||
| Refund.php | WePay\Refund | 微信商户退款 | 微信支付 | \We::WePayRefund() |
|
||||
| Transfers.php | WePay\Transfers | 微信商户打款到零钱 | 微信支付 | \We::WePayTransfers() |
|
||||
| TransfersBank.php | WePay\TransfersBank | 微信商户打款到银行卡 | 微信支付 | \We::WePayTransfersBank() |
|
||||
| Crypt.php | WeMini\Crypt | 微信小程序数据加密处理 | 微信小程序 | \We::WeMiniCrypt() |
|
||||
| Plugs.php | WeMini\Plugs | 微信小程序插件管理 | 微信小程序 | \We::WeMiniPlugs() |
|
||||
| Poi.php | WeMini\Poi | 微信小程序地址管理 | 微信小程序 | \We::WeMiniPoi() |
|
||||
| Qrcode.php | WeMini\Qrcode | 微信小程序二维码管理 | 微信小程序 | \We::WeMiniCrypt() |
|
||||
| Template.php | WeMini\Template | 微信小程序模板消息支持 | 微信小程序 | \We::WeMiniTemplate() |
|
||||
| Total.php | WeMini\Total | 微信小程序数据接口 | 微信小程序 | \We::WeMiniTotal() |
|
||||
|
||||
|
||||
Install
|
||||
--
|
||||
1.1 通过 Composer 来管理安装
|
||||
```shell
|
||||
# 首次安装 线上版本(稳定)
|
||||
composer require zoujingli/wechat-developer
|
||||
|
||||
# 首次安装 开发版本(开发)
|
||||
composer require zoujingli/wechat-developer dev-master
|
||||
|
||||
# 更新 WeChatDeveloper
|
||||
composer update zoujingli/wechat-developer
|
||||
```
|
||||
|
||||
1.2 如果不使用 Composer, 可以下载 WeChatDeveloper 并解压到项目中
|
||||
```php
|
||||
# 在项目中加载初始化文件
|
||||
include "您的目录/WeChatDeveloper/include.php";
|
||||
```
|
||||
|
||||
2.1 接口实例所需参数
|
||||
```php
|
||||
$config = [
|
||||
'token' => 'test',
|
||||
'appid' => 'wx60a43dd8161666d4',
|
||||
'appsecret' => '71308e96a204296c57d7cd4b21b883e8',
|
||||
'encodingaeskey' => 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5',
|
||||
// 配置商户支付参数(可选,在使用支付功能时需要)
|
||||
'mch_id' => "1235704602",
|
||||
'mch_key' => 'IKI4kpHjU94ji3oqre5zYaQMwLHuZPmj',
|
||||
// 配置商户支付双向证书目录(可选,在使用退款|打款|红包时需要)
|
||||
'ssl_key' => '',
|
||||
'ssl_cer' => '',
|
||||
// 缓存目录配置(可选,需拥有读写权限)
|
||||
'cache_path' => '',
|
||||
];
|
||||
```
|
||||
|
||||
3.1 实例指定接口
|
||||
```php
|
||||
try {
|
||||
|
||||
// 实例对应的接口对象
|
||||
$user = new \WeChat\User($config);
|
||||
|
||||
// 调用接口对象方法
|
||||
$list = $user->getUserList();
|
||||
|
||||
// 处理返回的结果
|
||||
echo '<pre>';
|
||||
var_export($list);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
// 出错啦,处理下吧
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Encapsulation
|
||||
--
|
||||
* 接入验证 (初级权限)
|
||||
* 自动回复(文本、图片、语音、视频、音乐、图文) (初级权限)
|
||||
* 菜单操作(查询、创建、删除) (菜单权限)
|
||||
* 客服消息(文本、图片、语音、视频、音乐、图文) (认证权限)
|
||||
* 二维码(创建临时、永久二维码,获取二维码URL) (服务号、认证权限)
|
||||
* 长链接转短链接接口 (服务号、认证权限)
|
||||
* 标签操作(查询、创建、修改、移动用户到标签) (认证权限)
|
||||
* 网页授权(基本授权,用户信息授权) (服务号、认证权限)
|
||||
* 用户信息(查询用户基本信息、获取关注者列表) (认证权限)
|
||||
* 多客服功能(客服管理、获取客服记录、客服会话管理) (认证权限)
|
||||
* 媒体文件(上传、获取) (认证权限)
|
||||
* 高级群发 (认证权限)
|
||||
* 模板消息(设置所属行业、添加模板、发送模板消息) (服务号、认证权限)
|
||||
* 卡券管理(创建、修改、删除、发放、门店管理等) (认证权限)
|
||||
* 语义理解 (服务号、认证权限)
|
||||
* 获取微信服务器IP列表 (初级权限)
|
||||
* 微信JSAPI授权(获取ticket、获取签名) (初级权限)
|
||||
* 数据统计(用户、图文、消息、接口分析数据) (认证权限)
|
||||
* 微信支付(网页支付、扫码支付、交易退款、给粉丝打款)(认证服务号并开通支付功能)
|
||||
|
||||
|
||||
Permission
|
||||
--
|
||||
* 初级权限:基本权限,任何正常的公众号都有此权限
|
||||
* 菜单权限:正常的服务号、认证后的订阅号拥有此权限
|
||||
* 认证权限:分为订阅号、服务号认证,如前缀服务号则仅认证的服务号有此权限
|
||||
* 支付权限:仅认证后的服务号可以申请此权限
|
||||
|
||||
|
||||
Copyright
|
||||
--
|
||||
* WeChatDeveloper 基于`MIT`协议发布,任何人可以用在任何地方,不受约束
|
||||
* WeChatDeveloper 部分代码来自互联网,若有异议,可以联系作者进行删除
|
||||
|
||||
|
||||
Sponsor
|
||||
--
|
||||

|
||||
|
||||
|
29
Test/config.php
Normal file
29
Test/config.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return [
|
||||
'token' => 'test',
|
||||
'appid' => 'wx60a43dd8161666d4',
|
||||
'appsecret' => '71308e96a204296c57d7cd4b21b883e8',
|
||||
'encodingaeskey' => 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5',
|
||||
// 配置商户支付参数
|
||||
'mch_id' => "1332187001",
|
||||
'mch_key' => 'A82DC5BD1F3359081049C568D8502BC5',
|
||||
// 配置商户支付双向证书目录 (p12 | key,cert 二选一,两者都配置时p12优先)
|
||||
// 'ssl_p12' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . 'apiclient_cert.p12',
|
||||
'ssl_key' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . 'apiclient_key.pem',
|
||||
'ssl_cer' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . 'apiclient_cert.pem',
|
||||
// 配置缓存目录,需要拥有写权限
|
||||
'cache_path' => '',
|
||||
];
|
20
Test/mini-login.php
Normal file
20
Test/mini-login.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
include '../include.php';
|
||||
|
||||
// 小程序配置
|
||||
$config = [
|
||||
'appid' => 'wx6bb7b70258da09c6',
|
||||
'appsecret' => '78b7b8d65bd67b078babf951d4342b42',
|
||||
];
|
||||
|
||||
// 解码数据
|
||||
$iv = 'ltM/wT7hsAl0TijEBI4v/g==';
|
||||
$code = '013LyiTR0TwjC92QjJRR0mEsTR0LyiT3';
|
||||
$decode = 'eIoVtIC2YzLCnrwiIs1IBbXMvC0vyL8bo1IhD38fUQIRbk3lgTWa0Hdw/Ty7NTs3iu7YlqqZBti+cxd6dCfeXBUQwTO2QpbHg0WTeDAdrihsHRHm4dCWdfTx8rzDloGbNOIsKdRElIhUH5YFdiTr5AYiufUDb34cwJ4GNWLAUq4bR0dmFeVEi+3nfwe2MAjGYDl4aq719VLsHodOggK6lXZvM5wjoDyuZsK2dPqJr3/Ji30Z0mdyFq32R4uR3rtJH/h+Rj0+/QmE9QYG7Y6Z48hgPE8cpnhRQNwH49jnC/zKZ9wtDkQ/J8J3Ed2i58zcuY01v8IV+pZ8oBUKXfO5ha+APOxtBSTzyHraU/2RGo8UWtOF6h64OQZhd/UQQy362eyc/qoq8sF9JnEFRP0mRmTDJ+u9oyDhxswCu6x8V73ERWaJeEGSCyjiGpep7/DxZ6eSSBq36OB0BWBkJqsq9Q==';
|
||||
$sessionKey = 'OetNxl86B/yMpbwG6wtMEw==';
|
||||
$mini = new WeMini\Crypt($config);
|
||||
echo '<pre>';
|
||||
//print_r($mini->session($code));
|
||||
print_r($mini->decode($iv, $sessionKey, $decode));
|
||||
//print_r($mini->userInfo($code, $iv, $decode));
|
25
Test/mini-qrc.php
Normal file
25
Test/mini-qrc.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
include '../include.php';
|
||||
|
||||
// 小程序配置
|
||||
$config = [
|
||||
'appid' => 'wx6bb7b70258da09c6',
|
||||
'appsecret' => '78b7b8d65bd67b078babf951d4342b42',
|
||||
];
|
||||
|
||||
//We::config($config);
|
||||
|
||||
$mini = We::WeMiniQrcode($config);
|
||||
|
||||
//$mini = new WeMini\Qrcode($config);
|
||||
|
||||
//echo '<pre>';
|
||||
try {
|
||||
header('Content-type:image/jpeg');//输出的类型
|
||||
// echo $mini->createDefault('pages/index?query=1');
|
||||
// echo $mini->createMiniScene('432432', 'pages/index/index');
|
||||
echo $mini->createMiniPath('pages/index?query=1');
|
||||
} catch (Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = '1217752501201407033233368018';
|
53
Test/pay-order-create.php
Normal file
53
Test/pay-order-create.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
|
||||
// 1. 手动加载入口文件
|
||||
include "../include.php";
|
||||
|
||||
// 2. 准备公众号配置参数
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
||||
'body' => '测试商品',
|
||||
'out_trade_no' => time(),
|
||||
'total_fee' => '1',
|
||||
'openid' => 'o38gpszoJoC9oJYz3UHHf6bEp0Lo',
|
||||
'trade_type' => 'JSAPI',
|
||||
'notify_url' => 'http://a.com/text.html',
|
||||
'spbill_create_ip' => '127.0.0.1',
|
||||
];
|
||||
// 生成预支付码
|
||||
$result = $wechat->createOrder($options);
|
||||
// 创建JSAPI参数签名
|
||||
$options = $wechat->createParamsForJsApi($result['prepay_id']);
|
||||
|
||||
echo '<pre>';
|
||||
echo "\n--- 创建预支付码 ---\n";
|
||||
var_export($result);
|
||||
|
||||
echo "\n\n--- JSAPI 及 H5 参数 ---\n";
|
||||
var_export($options);
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
// 出错啦,处理下吧
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,14 +21,12 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
||||
'transaction_id' => '1008450740201411110005820873',
|
||||
'out_refund_no' => '3241251235123',
|
||||
'out_refund_no' => '商户退款单号',
|
||||
'total_fee' => '1',
|
||||
'refund_fee' => '1',
|
||||
];
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = new \WeChat\Pay($config);
|
||||
// $wechat = \We::WeChatPay($config);
|
||||
$wechat = \WeChat\Pay::instance($config);
|
||||
$wechat = new \WeChat\Pay($config);
|
||||
|
||||
// 4. 组装参数,可以参考官方商户文档
|
||||
$options = [
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,12 +21,10 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = \We::WeChatScript($config);
|
||||
// $wechat = new \WeChat\Script($config);
|
||||
$wechat = \WeChat\Script::instance($config);
|
||||
$wechat = new \WeChat\Script($config);
|
||||
|
||||
// 4. 获取JSSDK网址签名配置
|
||||
$result = $wechat->getJsSign('https://a.com/test.php');
|
||||
$result = $wechat->getJsSign('http://a.com/test.php');
|
||||
|
||||
var_export($result);
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,13 +21,11 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $menu = \We::WeChatMenu($config);
|
||||
// $menu = new \WeChat\Menu($config);
|
||||
$menu = \WeChat\Menu::instance($config);
|
||||
$menu = new \WeChat\Menu($config);
|
||||
|
||||
// 4. 获取菜单数据
|
||||
$result = $menu->get();
|
||||
|
||||
|
||||
var_export($result);
|
||||
|
||||
} catch (Exception $e) {
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,9 +21,7 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = \We::WeChatQrcode($config);
|
||||
// $wechat = new \WeChat\Qrcode($config);
|
||||
$wechat = \WeChat\Qrcode::instance($config);
|
||||
$wechat = new \WeChat\Qrcode($config);
|
||||
|
||||
// 4. 获取用户列表
|
||||
$result = $wechat->create('场景内容');
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
try {
|
||||
@ -23,14 +21,11 @@ try {
|
||||
$config = include "./config.php";
|
||||
|
||||
// 3. 创建接口实例
|
||||
// $wechat = \We::WeChatUser($config);
|
||||
// $wechat = new \WeChat\User($config);
|
||||
$wechat = \WeChat\User::instance($config);
|
||||
$wechat = new \WeChat\User($config);
|
||||
|
||||
// 4. 获取用户列表
|
||||
$result = $wechat->getUserList();
|
||||
|
||||
echo '<pre>';
|
||||
var_export($result);
|
||||
|
||||
// 5. 批量获取用户资料
|
48
We.php
48
We.php
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use WeChat\Contracts\DataArray;
|
||||
@ -25,16 +23,6 @@ use WeChat\Exceptions\InvalidInstanceException;
|
||||
* @author Anyon<zoujingli@qq.com>
|
||||
* @date 2018/05/24 13:23
|
||||
*
|
||||
* ----- AliPay ----
|
||||
* @method \AliPay\App AliPayApp($options) static 支付宝App支付网关
|
||||
* @method \AliPay\Bill AliPayBill($options) static 支付宝电子面单下载
|
||||
* @method \AliPay\Pos AliPayPos($options) static 支付宝刷卡支付
|
||||
* @method \AliPay\Scan AliPayScan($options) static 支付宝扫码支付
|
||||
* @method \AliPay\Trade AliPayTrade($options) static 支付宝标准接口
|
||||
* @method \AliPay\Transfer AliPayTransfer($options) static 支付宝转账到账户
|
||||
* @method \AliPay\Wap AliPayWap($options) static 支付宝手机网站支付
|
||||
* @method \AliPay\Web AliPayWeb($options) static 支付宝网站支付
|
||||
*
|
||||
* ----- WeChat -----
|
||||
* @method \WeChat\Card WeChatCard($options = []) static 微信卡券管理
|
||||
* @method \WeChat\Custom WeChatCustom($options = []) static 微信客服消息
|
||||
@ -45,7 +33,7 @@ use WeChat\Exceptions\InvalidInstanceException;
|
||||
* @method \WeChat\Pay WeChatPay($options = []) static 微信支付商户
|
||||
* @method \WeChat\Product WeChatProduct($options = []) static 微信商店管理
|
||||
* @method \WeChat\Qrcode WeChatQrcode($options = []) static 微信二维码管理
|
||||
* @method \WeChat\Receive WeChatReceive($options = [], $showEchoStr = true) static 微信推送管理
|
||||
* @method \WeChat\Receive WeChatReceive($options = []) static 微信推送管理
|
||||
* @method \WeChat\Scan WeChatScan($options = []) static 微信扫一扫接入管理
|
||||
* @method \WeChat\Script WeChatScript($options = []) static 微信前端支持
|
||||
* @method \WeChat\Shake WeChatShake($options = []) static 微信揺一揺周边
|
||||
@ -53,41 +41,23 @@ use WeChat\Exceptions\InvalidInstanceException;
|
||||
* @method \WeChat\Template WeChatTemplate($options = []) static 微信模板消息
|
||||
* @method \WeChat\User WeChatUser($options = []) static 微信粉丝管理
|
||||
* @method \WeChat\Wifi WeChatWifi($options = []) static 微信门店WIFI管理
|
||||
* @method \WeChat\Draft WeChatDraft($options = []) static 微信草稿箱
|
||||
* @method \WeChat\Freepublish WeChatFreepublish($options = []) static 微信发布能力
|
||||
*
|
||||
* ----- WeMini -----
|
||||
* @method \WeMini\Crypt WeMiniCrypt($options = []) static 小程序数据加密处理
|
||||
* @method \WeMini\Delivery WeMiniDelivery($options = []) static 小程序即时配送
|
||||
* @method \WeMini\Shipping WeMiniShipping($options = []) satic 小程序发货信息
|
||||
* @method \WeMini\Guide WeMiniGuide($options = []) static 小程序导购助手
|
||||
* @method \WeMini\Image WeMiniImage($options = []) static 小程序图像处理
|
||||
* @method \WeMini\Live WeMiniLive($options = []) static 小程序直播接口
|
||||
* @method \WeMini\Logistics WeMiniLogistics($options = []) static 小程序物流助手
|
||||
* @method \WeMini\Message WeMiniMessage($options = []) static 小程序动态消息
|
||||
* @method \WeMini\Newtmpl WeMiniNewtmpl($options = []) static 小程序订阅消息
|
||||
* @method \WeMini\Ocr WeMiniOcr($options = []) static 小程序ORC服务
|
||||
* @method \WeMini\Operation WeMiniOperation($options = []) static 小程序运维中心
|
||||
* @method \WeMini\Plugs WeMiniPlugs($options = []) static 小程序插件管理
|
||||
* @method \WeMini\Poi WeMiniPoi($options = []) static 小程序地址管理
|
||||
* @method \WeMini\Qrcode WeMiniQrcode($options = []) static 小程序二维码管理
|
||||
* @method \WeMini\Scheme WeMiniScheme($options = []) static 小程序 URL-Scheme
|
||||
* @method \WeMini\Search WeMiniSearch($options = []) static 小程序搜索
|
||||
* @method \WeMini\Security WeMiniSecurity($options = []) static 小程序内容安全
|
||||
* @method \WeMini\Soter WeMiniSoter($options = []) static 小程序生物认证
|
||||
* @method \WeMini\Template WeMiniTemplate($options = []) static 小程序模板消息支持
|
||||
* @method \WeMini\Total WeMiniTotal($options = []) static 小程序数据接口
|
||||
*
|
||||
* ----- WePay -----
|
||||
* @method \WePay\Bill WePayBill($options = []) static 微信商户账单及评论
|
||||
* @method \WePay\Order WePayOrder($options = []) static 微信商户订单
|
||||
* @method \WePay\Coupon WePayCoupon($options = []) static 微信商户代金券
|
||||
* @method \WePay\Custom WePayCustom($options = []) static 微信商户海关
|
||||
* @method \WePay\Refund WePayRefund($options = []) static 微信商户退款
|
||||
* @method \WePay\Coupon WePayCoupon($options = []) static 微信商户代金券
|
||||
* @method \WePay\Redpack WePayRedpack($options = []) static 微信红包支持
|
||||
* @method \WePay\Transfers WePayTransfers($options = []) static 微信商户打款到零钱
|
||||
* @method \WePay\TransfersBank WePayTransfersBank($options = []) static 微信商户打款到银行卡
|
||||
* @method \WePay\ProfitSharing WePayProfitSharing($options = []) static 微信分账
|
||||
*/
|
||||
class We
|
||||
{
|
||||
@ -95,7 +65,7 @@ class We
|
||||
* 定义当前版本
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1.2.54';
|
||||
const VERSION = '1.1.12';
|
||||
|
||||
/**
|
||||
* 静态配置
|
||||
@ -132,10 +102,6 @@ class We
|
||||
$class = 'WeChat\\' . substr($name, 6);
|
||||
} elseif (substr($name, 0, 6) === 'WeMini') {
|
||||
$class = 'WeMini\\' . substr($name, 6);
|
||||
} elseif (substr($name, 0, 6) === 'AliPay') {
|
||||
$class = 'AliPay\\' . substr($name, 6);
|
||||
} elseif (substr($name, 0, 7) === 'WePayV3') {
|
||||
$class = 'WePayV3\\' . substr($name, 7);
|
||||
} elseif (substr($name, 0, 5) === 'WePay') {
|
||||
$class = 'WePay\\' . substr($name, 5);
|
||||
}
|
||||
@ -147,4 +113,4 @@ class We
|
||||
throw new InvalidInstanceException("class {$name} not found");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
308
WeChat/Card.php
308
WeChat/Card.php
@ -3,19 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
@ -35,35 +34,38 @@ class Card extends BasicWeChat
|
||||
public function create(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置买单接口
|
||||
* @param string $cardId
|
||||
* @param bool $isOpen
|
||||
* @param string $card_id
|
||||
* @param bool $is_open
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setPaycell($cardId, $isOpen = true)
|
||||
public function setPaycell($card_id, $is_open = true)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/paycell/set?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'is_open' => $isOpen]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自助核销接口
|
||||
* @param string $cardId
|
||||
* @param bool $isOpen
|
||||
* @param string $card_id
|
||||
* @param bool $is_open
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setConsumeCell($cardId, $isOpen = true)
|
||||
public function setConsumeCell($card_id, $is_open = true)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/selfconsumecell/set?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'is_open' => $isOpen]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,7 +78,8 @@ class Card extends BasicWeChat
|
||||
public function createQrc(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/qrcode/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,61 +92,66 @@ class Card extends BasicWeChat
|
||||
public function createLandingPage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/landingpage/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入自定义code
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @param array $code
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deposit($cardId, array $code)
|
||||
public function deposit($card_id, array $code)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'code' => $code]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入code数目
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getDepositCount($cardId)
|
||||
public function getDepositCount($card_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/code/getdepositcount?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核查code接口
|
||||
* @param string $cardId 进行导入code的卡券ID
|
||||
* @param string $card_id 进行导入code的卡券ID
|
||||
* @param array $code 已经微信卡券后台的自定义code,上限为100个
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function checkCode($cardId, array $code)
|
||||
public function checkCode($card_id, array $code)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/code/checkcode?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'code' => $code]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文消息群发卡券
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getNewsHtml($cardId)
|
||||
public function getNewsHtml($card_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/mpnews/gethtml?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,25 +165,27 @@ class Card extends BasicWeChat
|
||||
public function setTestWhiteList($openids = [], $usernames = [])
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/testwhitelist/set?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid' => $openids, 'username' => $usernames]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 线下核销查询Code
|
||||
* @param string $code 单张卡券的唯一标准
|
||||
* @param string $cardId 卡券ID代表一类卡券。自定义code卡券必填
|
||||
* @param bool $checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同
|
||||
* @param string $card_id 卡券ID代表一类卡券。自定义code卡券必填
|
||||
* @param bool $check_consume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCode($code, $cardId = null, $checkConsume = null)
|
||||
public function getCode($code, $card_id = null, $check_consume = null)
|
||||
{
|
||||
$data = ['code' => $code];
|
||||
is_null($cardId) || $data['card_id'] = $cardId;
|
||||
is_null($checkConsume) || $data['check_consume'] = $checkConsume;
|
||||
is_null($card_id) || $data['card_id'] = $card_id;
|
||||
is_null($check_consume) || $data['check_consume'] = $check_consume;
|
||||
$url = "https://api.weixin.qq.com/card/code/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,80 +201,86 @@ class Card extends BasicWeChat
|
||||
$data = ['code' => $code];
|
||||
is_null($card_id) || $data['card_id'] = $card_id;
|
||||
$url = "https://api.weixin.qq.com/card/code/consume?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code解码接口
|
||||
* @param string $encryptCode
|
||||
* @param string $encrypt_code
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function decrypt($encryptCode)
|
||||
public function decrypt($encrypt_code)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/code/decrypt?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['encrypt_code' => $encryptCode]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['encrypt_code' => $encrypt_code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户已领取卡券接口
|
||||
* @param string $openid
|
||||
* @param null|string $cardId
|
||||
* @param null|string $card_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardList($openid, $cardId = null)
|
||||
public function getCardList($openid, $card_id = null)
|
||||
{
|
||||
$data = ['openid' => $openid];
|
||||
is_null($cardId) || $data['card_id'] = $cardId;
|
||||
is_null($card_id) || $data['card_id'] = $card_id;
|
||||
$url = "https://api.weixin.qq.com/card/user/getcardlist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看卡券详情
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCard($cardId)
|
||||
public function getCard($card_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询卡券列表
|
||||
* @param int $offset 查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取
|
||||
* @param int $count 需要查询的卡片的数量(数量最大50)
|
||||
* @param array $statusList 支持开发者拉出指定状态的卡券列表
|
||||
* @param array $status_list 支持开发者拉出指定状态的卡券列表
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function batchGet($offset, $count = 50, array $statusList = [])
|
||||
public function batchGet($offset, $count = 50, array $status_list = [])
|
||||
{
|
||||
$data = ['offset' => $offset, 'count' => $count];
|
||||
empty($statusList) || $data['status_list'] = $statusList;
|
||||
empty($status_list) || $data['status_list'] = $status_list;
|
||||
$url = "https://api.weixin.qq.com/card/batchget?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改卡券信息接口
|
||||
* @param string $cardId
|
||||
* @param array $memberCard
|
||||
* @param string $card_id
|
||||
* @param array $member_card
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateCard($cardId, array $memberCard)
|
||||
public function updateCard($card_id, array $member_card)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'member_card' => $memberCard]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'member_card' => $member_card]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,10 +295,11 @@ class Card extends BasicWeChat
|
||||
public function modifyStock($card_id, $increase_stock_value = null, $reduce_stock_value = null)
|
||||
{
|
||||
$data = ['card_id' => $card_id];
|
||||
is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value;
|
||||
is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value;
|
||||
is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value;
|
||||
$url = "https://api.weixin.qq.com/card/modifystock?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,71 +316,76 @@ class Card extends BasicWeChat
|
||||
$data = ['code' => $code, 'new_code' => $new_code];
|
||||
is_null($card_id) || $data['card_id'] = $card_id;
|
||||
$url = "https://api.weixin.qq.com/card/code/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卡券接口
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteCard($cardId)
|
||||
public function deleteCard($card_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券失效接口
|
||||
* @param string $code
|
||||
* @param string $cardId
|
||||
* @param string $card_id
|
||||
* @param null|string $reason
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function unAvailable($code, $cardId, $reason = null)
|
||||
public function unAvailable($code, $card_id, $reason = null)
|
||||
{
|
||||
$data = ['code' => $code, 'card_id' => $cardId];
|
||||
$data = ['code' => $code, 'card_id' => $card_id];
|
||||
is_null($reason) || $data['reason'] = $reason;
|
||||
$url = "https://api.weixin.qq.com/card/code/unavailable?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取卡券概况数据接口
|
||||
* @param string $beginDate 查询数据的起始时间
|
||||
* @param string $endDate 查询数据的截至时间
|
||||
* @param string $condSource 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
|
||||
* @param string $begin_date 查询数据的起始时间
|
||||
* @param string $end_date 查询数据的截至时间
|
||||
* @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardBizuininfo($beginDate, $endDate, $condSource)
|
||||
public function getCardBizuininfo($begin_date, $end_date, $cond_source)
|
||||
{
|
||||
$data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
|
||||
$url = "https://api.weixin.qq.com/datacube/getcardbizuininfo?access_token=ACCESS_TOKEN";
|
||||
$data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource];
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取免费券数据接口
|
||||
* @param string $beginDate 查询数据的起始时间
|
||||
* @param string $endDate 查询数据的截至时间
|
||||
* @param integer $condSource 卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据
|
||||
* @param null $cardId 卡券ID
|
||||
* @param string $begin_date 查询数据的起始时间
|
||||
* @param string $end_date 查询数据的截至时间
|
||||
* @param integer $cond_source 卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据
|
||||
* @param null $card_id 卡券ID
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardCardinfo($beginDate, $endDate, $condSource, $cardId = null)
|
||||
public function getCardCardinfo($begin_date, $end_date, $cond_source, $card_id = null)
|
||||
{
|
||||
$data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
|
||||
is_null($card_id) || $data['card_id'] = $card_id;
|
||||
$url = "https://api.weixin.qq.com/datacube/getcardcardinfo?access_token=ACCESS_TOKEN";
|
||||
$data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource];
|
||||
is_null($cardId) || $data['card_id'] = $cardId;
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
|
||||
@ -377,7 +399,8 @@ class Card extends BasicWeChat
|
||||
public function activateMemberCard(array $data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/card/membercard/activate?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,21 +414,23 @@ class Card extends BasicWeChat
|
||||
public function setActivateMemberCardUser(array $data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户提交资料
|
||||
* 根据activate_ticket获取到用户填写的信息
|
||||
* @param string $activateTicket
|
||||
* @param string $activate_ticket
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getActivateMemberCardTempinfo($activateTicket)
|
||||
public function getActivateMemberCardTempinfo($activate_ticket)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['activate_ticket' => $activateTicket]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['activate_ticket' => $activate_ticket]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,54 +443,58 @@ class Card extends BasicWeChat
|
||||
public function updateMemberCardUser(array $data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/card/membercard/updateuser?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取会员卡概况数据接口
|
||||
* @param string $beginDate 查询数据的起始时间
|
||||
* @param string $endDate 查询数据的截至时间
|
||||
* @param string $condSource 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
|
||||
* @param string $begin_date 查询数据的起始时间
|
||||
* @param string $end_date 查询数据的截至时间
|
||||
* @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据)
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardMemberCardinfo($beginDate, $endDate, $condSource)
|
||||
public function getCardMemberCardinfo($begin_date, $end_date, $cond_source)
|
||||
{
|
||||
$data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source];
|
||||
$url = "https://api.weixin.qq.com/datacube/getcardmembercardinfo?access_token=ACCESS_TOKEN";
|
||||
$data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource];
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取单张会员卡数据接口
|
||||
* @param string $beginDate 查询数据的起始时间
|
||||
* @param string $endDate 查询数据的截至时间
|
||||
* @param string $cardId 卡券id
|
||||
* @param string $begin_date 查询数据的起始时间
|
||||
* @param string $end_date 查询数据的截至时间
|
||||
* @param string $card_id 卡券id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardMemberCardDetail($beginDate, $endDate, $cardId)
|
||||
public function getCardMemberCardDetail($begin_date, $end_date, $card_id)
|
||||
{
|
||||
$data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'card_id' => $card_id];
|
||||
$url = "https://api.weixin.qq.com/datacube/getcardmembercarddetail?access_token=ACCESS_TOKEN";
|
||||
$data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'card_id' => $cardId];
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取会员信息(积分查询)接口
|
||||
* @param string $cardId 查询会员卡的cardid
|
||||
* @param string $card_id 查询会员卡的cardid
|
||||
* @param string $code 所查询用户领取到的code值
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCardMemberCard($cardId, $code)
|
||||
public function getCardMemberCard($card_id, $code)
|
||||
{
|
||||
$data = ['card_id' => $cardId, 'code' => $code];
|
||||
$data = ['card_id' => $card_id, 'code' => $code];
|
||||
$url = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -478,33 +507,36 @@ class Card extends BasicWeChat
|
||||
public function payGiftCard(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除支付后投放卡券规则
|
||||
* @param integer $ruleId 支付即会员的规则名称
|
||||
* @param integer $rule_id 支付即会员的规则名称
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delPayGiftCard($ruleId)
|
||||
public function delPayGiftCard($rule_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['rule_id' => $ruleId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付后投放卡券规则详情
|
||||
* @param integer $ruleId 要查询规则id
|
||||
* @param integer $rule_id 要查询规则id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPayGiftCard($ruleId)
|
||||
public function getPayGiftCard($rule_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/paygiftcard/getbyid?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['rule_id' => $ruleId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['rule_id' => $rule_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,9 +550,10 @@ class Card extends BasicWeChat
|
||||
*/
|
||||
public function batchGetPayGiftCard($offset = 0, $count = 10, $effective = true)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=ACCESS_TOKEN";
|
||||
$data = ['type' => 'RULE_TYPE_PAY_MEMBER_CARD', 'offset' => $offset, 'count' => $count, 'effective' => $effective];
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,7 +566,8 @@ class Card extends BasicWeChat
|
||||
public function addActivity(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/mkt/activity/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,21 +579,23 @@ class Card extends BasicWeChat
|
||||
public function payActivate()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/pay/activate?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对优惠券批价
|
||||
* @param string $cardId 需要来配置库存的card_id
|
||||
* @param string $card_id 需要来配置库存的card_id
|
||||
* @param integer $quantity 本次需要兑换的库存数目
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPayprice($cardId, $quantity)
|
||||
public function getPayprice($card_id, $quantity)
|
||||
{
|
||||
$url = "POST https://api.weixin.qq.com/card/pay/getpayprice?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['card_id' => $cardId, 'quantity' => $quantity]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['card_id' => $card_id, 'quantity' => $quantity]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -571,49 +607,53 @@ class Card extends BasicWeChat
|
||||
public function getCoinsInfo()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/pay/getcoinsinfo?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认兑换库存接口
|
||||
* @param string $cardId 需要来兑换库存的card_id
|
||||
* @param string $card_id 需要来兑换库存的card_id
|
||||
* @param integer $quantity 本次需要兑换的库存数目
|
||||
* @param string $orderId 仅可以使用上面得到的订单号,保证批价有效性
|
||||
* @param string $order_id 仅可以使用上面得到的订单号,保证批价有效性
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function payConfirm($cardId, $quantity, $orderId)
|
||||
public function payConfirm($card_id, $quantity, $order_id)
|
||||
{
|
||||
$data = ['card_id' => $card_id, 'quantity' => $quantity, 'order_id' => $order_id];
|
||||
$url = "https://api.weixin.qq.com/card/pay/confirm?access_token=ACCESS_TOKEN";
|
||||
$data = ['card_id' => $cardId, 'quantity' => $quantity, 'order_id' => $orderId];
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值券点接口
|
||||
* @param integer $coinCount
|
||||
* @param integer $coin_count
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function payRecharge($coinCount)
|
||||
public function payRecharge($coin_count)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/pay/recharge?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['coin_count' => $coinCount]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['coin_count' => $coin_count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单详情接口
|
||||
* @param string $orderId
|
||||
* @param string $order_id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function payGetOrder($orderId)
|
||||
public function payGetOrder($order_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/pay/getorder?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['order_id' => $orderId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['order_id' => $order_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -626,19 +666,9 @@ class Card extends BasicWeChat
|
||||
public function payGetList(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/pay/getorderlist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开卡插件参数
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getActivateUrl(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/card/membercard/activate/geturl?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
}
|
||||
|
||||
}
|
@ -1,428 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
|
||||
use WeChat\Exceptions\InvalidArgumentException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
/**
|
||||
* 支付宝支付基类
|
||||
* Class AliPay
|
||||
* @package AliPay\Contracts
|
||||
*/
|
||||
abstract class BasicAliPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 支持配置
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* 当前请求数据
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* DzContent数据
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* 静态缓存
|
||||
* @var static
|
||||
*/
|
||||
protected static $cache;
|
||||
|
||||
/**
|
||||
* 正常请求网关
|
||||
* @var string
|
||||
*/
|
||||
protected $gateway = 'https://openapi.alipay.com/gateway.do?charset=utf-8';
|
||||
|
||||
/**
|
||||
* AliPay constructor.
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($options)
|
||||
{
|
||||
if (empty($options['appid'])) {
|
||||
throw new InvalidArgumentException('Missing Config -- [appid]');
|
||||
}
|
||||
if (empty($options['public_key']) && !empty($options['alipay_cert_path']) && is_file($options['alipay_cert_path'])) {
|
||||
$options['public_key'] = file_get_contents($options['alipay_cert_path']);
|
||||
}
|
||||
if (empty($options['private_key']) && !empty($options['private_key_path']) && is_file($options['private_key_path'])) {
|
||||
$options['private_key'] = file_get_contents($options['private_key_path']);
|
||||
}
|
||||
if (empty($options['public_key'])) {
|
||||
throw new InvalidArgumentException('Missing Config -- [public_key]');
|
||||
}
|
||||
if (empty($options['private_key'])) {
|
||||
throw new InvalidArgumentException('Missing Config -- [private_key]');
|
||||
}
|
||||
if (!empty($options['debug'])) {
|
||||
$this->gateway = 'https://openapi-sandbox.dl.alipaydev.com/gateway.do?charset=utf-8';
|
||||
}
|
||||
$this->params = new DataArray([]);
|
||||
$this->config = new DataArray($options);
|
||||
$this->options = new DataArray([
|
||||
'app_id' => $this->config->get('appid'),
|
||||
'charset' => empty($options['charset']) ? 'utf-8' : $options['charset'],
|
||||
'format' => 'JSON',
|
||||
'version' => '1.0',
|
||||
'sign_type' => empty($options['sign_type']) ? 'RSA2' : $options['sign_type'],
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
if (isset($options['notify_url']) && $options['notify_url'] !== '') {
|
||||
$this->options->set('notify_url', $options['notify_url']);
|
||||
}
|
||||
if (isset($options['return_url']) && $options['return_url'] !== '') {
|
||||
$this->options->set('return_url', $options['return_url']);
|
||||
}
|
||||
if (isset($options['app_auth_token']) && $options['app_auth_token'] !== '') {
|
||||
$this->options->set('app_auth_token', $options['app_auth_token']);
|
||||
}
|
||||
|
||||
// 证书模式读取证书
|
||||
$appCertPath = $this->config->get('app_cert_path');
|
||||
$aliRootPath = $this->config->get('alipay_root_path');
|
||||
if (!$this->config->get('app_cert') && !empty($appCertPath) && is_file($appCertPath)) {
|
||||
$this->config->set('app_cert', file_get_contents($appCertPath));
|
||||
}
|
||||
if (!$this->config->get('root_cert') && !empty($aliRootPath) && is_file($aliRootPath)) {
|
||||
$this->config->set('root_cert', file_get_contents($aliRootPath));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态创建对象
|
||||
* @param array $config
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(array $config)
|
||||
{
|
||||
$key = md5(get_called_class() . serialize($config));
|
||||
if (isset(self::$cache[$key])) return self::$cache[$key];
|
||||
return self::$cache[$key] = new static($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付宝订单状态
|
||||
* @param string $outTradeNo
|
||||
* @return array|boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($outTradeNo = '')
|
||||
{
|
||||
$this->options->set('method', 'alipay.trade.query');
|
||||
return $this->getResult(['out_trade_no' => $outTradeNo]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝订单退款操作
|
||||
* @param array|string $options 退款参数或退款商户订单号
|
||||
* @param null $refundAmount 退款金额
|
||||
* @return array|boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function refund($options, $refundAmount = null)
|
||||
{
|
||||
if (!is_array($options)) $options = ['out_trade_no' => $options, 'refund_amount' => $refundAmount];
|
||||
$this->options->set('method', 'alipay.trade.refund');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭支付宝进行中的订单
|
||||
* @param array|string $options
|
||||
* @return array|boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function close($options)
|
||||
{
|
||||
if (!is_array($options)) $options = ['out_trade_no' => $options];
|
||||
$this->options->set('method', 'alipay.trade.close');
|
||||
return $this->getResult($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通知数据
|
||||
*
|
||||
* @param boolean $needSignType 是否需要sign_type字段
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function notify($needSignType = false, array $parameters = [])
|
||||
{
|
||||
$data = empty($parameters) ? $_POST : $parameters;
|
||||
|
||||
if (empty($data) || empty($data['sign'])) {
|
||||
throw new InvalidResponseException('Illegal push request.', 0, $data);
|
||||
}
|
||||
$string = $this->getSignContent($data, $needSignType);
|
||||
if (openssl_verify($string, base64_decode($data['sign']), $this->getAliPublicKey(), OPENSSL_ALGO_SHA256) !== 1) {
|
||||
throw new InvalidResponseException('Data signature verification failed.', 0, $data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证接口返回的数据签名
|
||||
* @param array $data 通知数据
|
||||
* @param null|string $sign 数据签名
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
protected function verify($data, $sign)
|
||||
{
|
||||
unset($data['sign']);
|
||||
if ($this->options->get('sign_type') === 'RSA2') {
|
||||
if (openssl_verify(json_encode($data, 256), base64_decode($sign), $this->getAliPublicKey(), OPENSSL_ALGO_SHA256) !== 1) {
|
||||
throw new InvalidResponseException('Data signature verification failed by RSA2.');
|
||||
}
|
||||
} else {
|
||||
if (openssl_verify(json_encode($data, 256), base64_decode($sign), $this->getAliPublicKey(), OPENSSL_ALGO_SHA1) !== 1) {
|
||||
throw new InvalidResponseException('Data signature verification failed by RSA.');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据签名
|
||||
* @return string
|
||||
*/
|
||||
protected function getSign()
|
||||
{
|
||||
if ($this->options->get('sign_type') === 'RSA2') {
|
||||
openssl_sign($this->getSignContent($this->options->get(), true), $sign, $this->getAppPrivateKey(), OPENSSL_ALGO_SHA256);
|
||||
} else {
|
||||
openssl_sign($this->getSignContent($this->options->get(), true), $sign, $this->getAppPrivateKey(), OPENSSL_ALGO_SHA1);
|
||||
}
|
||||
return base64_encode($sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除证书前后内容及空白
|
||||
* @param string $sign
|
||||
* @return string
|
||||
*/
|
||||
protected function trimCert($sign)
|
||||
{
|
||||
return preg_replace(['/\s+/', '/-{5}.*?-{5}/'], '', $sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据签名处理
|
||||
* @param array $data 需要进行签名数据
|
||||
* @param boolean $needSignType 是否需要sign_type字段
|
||||
* @return string
|
||||
*/
|
||||
private function getSignContent(array $data, $needSignType = false)
|
||||
{
|
||||
list($attrs,) = [[], ksort($data)];
|
||||
if (isset($data['sign'])) unset($data['sign']);
|
||||
if (empty($needSignType)) unset($data['sign_type']);
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value === '' || is_null($value)) continue;
|
||||
$attrs[] = "{$key}={$value}";
|
||||
}
|
||||
return join('&', $attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据包生成及数据签名
|
||||
* @param array $options
|
||||
*/
|
||||
protected function applyData($options)
|
||||
{
|
||||
if ($this->config->get('app_cert') && $this->config->get('root_cert')) {
|
||||
$this->setAppCertSnAndRootCertSn();
|
||||
}
|
||||
$this->options->set('biz_content', json_encode($this->params->merge($options), 256));
|
||||
$this->options->set('sign', $this->getSign());
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求接口并验证访问数据
|
||||
* @param array $options
|
||||
* @return array|boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
protected function getResult($options)
|
||||
{
|
||||
$this->applyData($options);
|
||||
$method = str_replace('.', '_', $this->options['method']) . '_response';
|
||||
$data = json_decode(Tools::get($this->gateway, $this->options->get()), true);
|
||||
if (!isset($data[$method]['code']) || $data[$method]['code'] !== '10000') {
|
||||
throw new InvalidResponseException(
|
||||
"Error: " .
|
||||
(empty($data[$method]['code']) ? '' : "{$data[$method]['msg']} [{$data[$method]['code']}]\r\n") .
|
||||
(empty($data[$method]['sub_code']) ? '' : "{$data[$method]['sub_msg']} [{$data[$method]['sub_code']}]\r\n"),
|
||||
$data[$method]['code'], $data
|
||||
);
|
||||
}
|
||||
return $data[$method];
|
||||
// 返回结果签名检查
|
||||
// return $this->verify($data[$method], $data['sign']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付HTML代码
|
||||
* @return string
|
||||
*/
|
||||
protected function buildPayHtml()
|
||||
{
|
||||
$html = "<form id='alipaysubmit' name='alipaysubmit' action='{$this->gateway}' method='post'>";
|
||||
foreach ($this->options->get() as $key => $value) {
|
||||
$value = str_replace("'", ''', $value);
|
||||
$html .= "<input type='hidden' name='{$key}' value='{$value}'/>";
|
||||
}
|
||||
$html .= "<input type='submit' value='ok' style='display:none;'></form>";
|
||||
return "{$html}<script>document.forms['alipaysubmit'].submit();</script>";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用私钥内容
|
||||
* @return string
|
||||
*/
|
||||
private function getAppPrivateKey()
|
||||
{
|
||||
$content = wordwrap($this->trimCert($this->config->get('private_key')), 64, "\n", true);
|
||||
return "-----BEGIN RSA PRIVATE KEY-----\n{$content}\n-----END RSA PRIVATE KEY-----";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付公钥内容
|
||||
* @return string
|
||||
*/
|
||||
public function getAliPublicKey()
|
||||
{
|
||||
$cert = $this->config->get('public_key');
|
||||
if (strpos(trim($cert), '-----BEGIN CERTIFICATE-----') !== false) {
|
||||
$pkey = openssl_pkey_get_public($cert);
|
||||
$keyData = openssl_pkey_get_details($pkey);
|
||||
return trim($keyData['key']);
|
||||
} else {
|
||||
$content = wordwrap($this->trimCert($cert), 64, "\n", true);
|
||||
return "-----BEGIN PUBLIC KEY-----\n{$content}\n-----END PUBLIC KEY-----";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 从证书中提取序列号
|
||||
* @param string $sign
|
||||
* @return string
|
||||
*/
|
||||
private function getAppCertSN($sign)
|
||||
{
|
||||
$ssl = openssl_x509_parse($sign, true);
|
||||
return md5($this->_arr2str(array_reverse($ssl['issuer'])) . $ssl['serialNumber']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 提取根证书序列号
|
||||
* @param string $sign
|
||||
* @return string|null
|
||||
*/
|
||||
private function getRootCertSN($sign)
|
||||
{
|
||||
$sn = null;
|
||||
$array = explode('-----END CERTIFICATE-----', $sign);
|
||||
for ($i = 0; $i < count($array) - 1; $i++) {
|
||||
$ssl[$i] = openssl_x509_parse($array[$i] . '-----END CERTIFICATE-----', true);
|
||||
if (strpos($ssl[$i]['serialNumber'], '0x') === 0) {
|
||||
$ssl[$i]['serialNumber'] = $this->_hex2dec($ssl[$i]['serialNumberHex']);
|
||||
}
|
||||
if ($ssl[$i]['signatureTypeLN'] == 'sha1WithRSAEncryption' || $ssl[$i]['signatureTypeLN'] == 'sha256WithRSAEncryption') {
|
||||
if ($sn == null) {
|
||||
$sn = md5($this->_arr2str(array_reverse($ssl[$i]['issuer'])) . $ssl[$i]['serialNumber']);
|
||||
} else {
|
||||
$sn = $sn . '_' . md5($this->_arr2str(array_reverse($ssl[$i]['issuer'])) . $ssl[$i]['serialNumber']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 设置网关应用公钥证书SN、支付宝根证书SN
|
||||
*/
|
||||
protected function setAppCertSnAndRootCertSn()
|
||||
{
|
||||
if (!($appCert = $this->config->get('app_cert'))) {
|
||||
throw new InvalidArgumentException('Missing Config -- [app_cert|app_cert_path]');
|
||||
}
|
||||
if (!($rootCert = $this->config->get('root_cert'))) {
|
||||
throw new InvalidArgumentException('Missing Config -- [root_cert|alipay_root_path]');
|
||||
}
|
||||
$this->options->set('app_cert_sn', $this->getAppCertSN($appCert));
|
||||
$this->options->set('alipay_root_cert_sn', $this->getRootCertSN($rootCert));
|
||||
if (!$this->options->get('app_cert_sn')) {
|
||||
throw new InvalidArgumentException('Missing options -- [app_cert_sn]');
|
||||
}
|
||||
if (!$this->options->get('alipay_root_cert_sn')) {
|
||||
throw new InvalidArgumentException('Missing options -- [alipay_root_cert_sn]');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 数组转字符串
|
||||
* @param array $array
|
||||
* @return string
|
||||
*/
|
||||
private function _arr2str($array)
|
||||
{
|
||||
$string = [];
|
||||
if ($array && is_array($array)) {
|
||||
foreach ($array as $key => $value) {
|
||||
$string[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
return join(',', $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版 0x转高精度数字
|
||||
* @param string $hex
|
||||
* @return int|string
|
||||
*/
|
||||
private function _hex2dec($hex)
|
||||
{
|
||||
list($dec, $len) = [0, strlen($hex)];
|
||||
for ($i = 1; $i <= $len; $i++) {
|
||||
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len - $i))));
|
||||
}
|
||||
return $dec;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用数据操作
|
||||
* @param array $options
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function apply($options);
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
@ -24,7 +22,7 @@ use WeChat\Exceptions\InvalidResponseException;
|
||||
* Class BasicPay
|
||||
* @package WeChat\Contracts
|
||||
*/
|
||||
class BasicWePay
|
||||
class BasicPay
|
||||
{
|
||||
/**
|
||||
* 商户配置
|
||||
@ -38,11 +36,6 @@ class BasicWePay
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* 静态缓存
|
||||
* @var static
|
||||
*/
|
||||
protected static $cache;
|
||||
|
||||
/**
|
||||
* WeChat constructor.
|
||||
@ -78,42 +71,20 @@ class BasicWePay
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态创建对象
|
||||
* @param array $config
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(array $config)
|
||||
{
|
||||
$key = md5(get_called_class() . serialize($config));
|
||||
if (isset(self::$cache[$key])) return self::$cache[$key];
|
||||
return self::$cache[$key] = new static($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信支付通知
|
||||
* @param string|array $xml
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function getNotify($xml = '')
|
||||
public function getNotify()
|
||||
{
|
||||
$data = is_array($xml) ? $xml : Tools::xml2arr(empty($xml) ? Tools::getRawInput() : $xml);
|
||||
$data = Tools::xml2arr(file_get_contents('php://input'));
|
||||
if (isset($data['sign']) && $this->getPaySign($data) === $data['sign']) {
|
||||
return $data;
|
||||
}
|
||||
throw new InvalidResponseException('Invalid Notify.', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信支付通知回复内容
|
||||
* @return string
|
||||
*/
|
||||
public function getNotifySuccessReply()
|
||||
{
|
||||
return Tools::arr2xml(['return_code' => 'SUCCESS', 'return_msg' => 'OK']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付签名
|
||||
* @param array $data 参与签名的数据
|
||||
@ -125,10 +96,7 @@ class BasicWePay
|
||||
{
|
||||
ksort($data);
|
||||
if (isset($data['sign'])) unset($data['sign']);
|
||||
foreach ($data as $k => $v) {
|
||||
if ('' === $v || null === $v) continue;
|
||||
$buff .= "{$k}={$v}&";
|
||||
}
|
||||
foreach ($data as $k => $v) $buff .= "{$k}={$v}&";
|
||||
$buff .= ("key=" . $this->config->get('mch_key'));
|
||||
if (strtoupper($signType) === 'MD5') {
|
||||
return strtoupper(md5($buff));
|
||||
@ -140,7 +108,7 @@ class BasicWePay
|
||||
* 转换短链接
|
||||
* @param string $longUrl 需要转换的URL,签名用原串,传输需URLencode
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function shortUrl($longUrl)
|
||||
@ -149,32 +117,34 @@ class BasicWePay
|
||||
return $this->callPostApi($url, ['long_url' => $longUrl]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数组直接转xml数据输出
|
||||
* @param array $data
|
||||
* @param bool $isReturn
|
||||
* @return string|void
|
||||
* @return string
|
||||
*/
|
||||
public function toXml(array $data, $isReturn = false)
|
||||
{
|
||||
$xml = Tools::arr2xml($data);
|
||||
if ($isReturn) return $xml;
|
||||
if ($isReturn) {
|
||||
return $xml;
|
||||
}
|
||||
echo $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 Post 请求接口
|
||||
* 以Post请求接口
|
||||
* @param string $url 请求
|
||||
* @param array $data 接口参数
|
||||
* @param bool $isCert 是否需要使用双向证书
|
||||
* @param string $signType 数据签名类型 MD5|SHA256
|
||||
* @param bool $needSignType 是否需要传签名类型参数
|
||||
* @param bool $needNonceStr
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
protected function callPostApi($url, array $data, $isCert = false, $signType = 'HMAC-SHA256', $needSignType = true, $needNonceStr = true)
|
||||
protected function callPostApi($url, array $data, $isCert = false, $signType = 'HMAC-SHA256', $needSignType = true)
|
||||
{
|
||||
$option = [];
|
||||
if ($isCert) {
|
||||
@ -196,8 +166,7 @@ class BasicWePay
|
||||
}
|
||||
}
|
||||
$params = $this->params->merge($data);
|
||||
if (!$needNonceStr) unset($params['nonce_str']);
|
||||
if ($needSignType) $params['sign_type'] = strtoupper($signType);
|
||||
$needSignType && ($params['sign_type'] = strtoupper($signType));
|
||||
$params['sign'] = $this->getPaySign($params, $signType);
|
||||
$result = Tools::xml2arr(Tools::post($url, Tools::arr2xml($params), $option));
|
||||
if ($result['return_code'] !== 'SUCCESS') {
|
||||
@ -205,4 +174,4 @@ class BasicWePay
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
@ -19,7 +17,6 @@ namespace WeChat\Contracts;
|
||||
use WeChat\Exceptions\InvalidArgumentException;
|
||||
use WeChat\Exceptions\InvalidDecryptException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Prpcrypt\Prpcrypt;
|
||||
|
||||
/**
|
||||
* 微信通知处理基本类
|
||||
@ -46,18 +43,18 @@ class BasicPushEvent
|
||||
*/
|
||||
protected $encryptType;
|
||||
|
||||
/**
|
||||
* 公众号的推送请求参数
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $input;
|
||||
|
||||
/**
|
||||
* 当前公众号配置对象
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* 公众号的推送请求参数
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* 公众号推送内容对象
|
||||
* @var DataArray
|
||||
@ -72,11 +69,10 @@ class BasicPushEvent
|
||||
|
||||
/**
|
||||
* BasicPushEvent constructor.
|
||||
* @param array $options 配置参数
|
||||
* @param boolean $showEchoStr 回显内容
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @param array $options
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function __construct(array $options, $showEchoStr = true)
|
||||
public function __construct(array $options)
|
||||
{
|
||||
if (empty($options['appid'])) {
|
||||
throw new InvalidArgumentException("Missing Config -- [appid]");
|
||||
@ -89,17 +85,20 @@ class BasicPushEvent
|
||||
}
|
||||
// 参数初始化
|
||||
$this->config = new DataArray($options);
|
||||
$this->input = new DataArray($_REQUEST);
|
||||
$this->params = new DataArray($_REQUEST);
|
||||
$this->appid = $this->config->get('appid');
|
||||
// 推送消息处理
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$this->postxml = Tools::getRawInput();
|
||||
$this->encryptType = $this->input->get('encrypt_type');
|
||||
if ($this->isEncrypt()) {
|
||||
$this->postxml = file_get_contents("php://input");
|
||||
$this->encryptType = $this->params->get('encrypt_type');
|
||||
if ($this->encryptType == 'aes') {
|
||||
if (empty($options['encodingaeskey'])) {
|
||||
throw new InvalidArgumentException("Missing Config -- [encodingaeskey]");
|
||||
}
|
||||
$prpcrypt = new Prpcrypt($this->config->get('encodingaeskey'));
|
||||
if (!class_exists('Prpcrypt', false)) {
|
||||
require __DIR__ . '/Prpcrypt.php';
|
||||
}
|
||||
$prpcrypt = new \Prpcrypt($this->config->get('encodingaeskey'));
|
||||
$result = Tools::xml2arr($this->postxml);
|
||||
$array = $prpcrypt->decrypt($result['Encrypt']);
|
||||
if (intval($array[0]) > 0) {
|
||||
@ -109,55 +108,35 @@ class BasicPushEvent
|
||||
}
|
||||
$this->receive = new DataArray(Tools::xml2arr($this->postxml));
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] == "GET" && $this->checkSignature()) {
|
||||
$this->receive = new DataArray([]);
|
||||
if ($showEchoStr && ob_clean()) {
|
||||
echo($this->input->get('echostr'));
|
||||
}
|
||||
@ob_clean();
|
||||
exit($this->params->get('echostr'));
|
||||
} else {
|
||||
throw new InvalidResponseException('Invalid interface request.', '0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取回显字串
|
||||
* @return string
|
||||
*/
|
||||
public function getEchoStr()
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET" && $this->checkSignature()) {
|
||||
return $this->input->get('echostr');
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息是否需要加密
|
||||
* @return boolean
|
||||
*/
|
||||
public function isEncrypt()
|
||||
{
|
||||
return $this->encryptType === 'aes';
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复消息
|
||||
* @param array $data 消息内容
|
||||
* @param boolean $return 是否返回XML内容
|
||||
* @param boolean $isEncrypt 是否加密内容
|
||||
* @return string|void
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @param bool $return 是否返回XML内容
|
||||
* @return string
|
||||
* @throws InvalidDecryptException
|
||||
*/
|
||||
public function reply(array $data = [], $return = false, $isEncrypt = false)
|
||||
public function reply(array $data = [], $return = false)
|
||||
{
|
||||
$xml = Tools::arr2xml(empty($data) ? $this->message : $data);
|
||||
if ($this->isEncrypt() || $isEncrypt) {
|
||||
$prpcrypt = new Prpcrypt($this->config->get('encodingaeskey'));
|
||||
if ($this->encryptType == 'aes') {
|
||||
if (!class_exists('Prpcrypt', false)) {
|
||||
require __DIR__ . '/Prpcrypt.php';
|
||||
}
|
||||
$prpcrypt = new \Prpcrypt($this->config->get('encodingaeskey'));
|
||||
// 如果是第三方平台,加密得使用 component_appid
|
||||
$component_appid = $this->config->get('component_appid');
|
||||
$appid = empty($component_appid) ? $this->appid : $component_appid;
|
||||
$array = $prpcrypt->encrypt($xml, $appid);
|
||||
if ($array[0] > 0) throw new InvalidDecryptException('Encrypt Error.', '0');
|
||||
if ($array[0] > 0) {
|
||||
throw new InvalidDecryptException('Encrypt Error.', '0');
|
||||
}
|
||||
list($timestamp, $encrypt) = [time(), $array[1]];
|
||||
$nonce = rand(77, 999) * rand(605, 888) * rand(11, 99);
|
||||
$tmpArr = [$this->config->get('token'), $timestamp, $nonce, $encrypt];
|
||||
@ -166,24 +145,30 @@ class BasicPushEvent
|
||||
$format = "<xml><Encrypt><![CDATA[%s]]></Encrypt><MsgSignature><![CDATA[%s]]></MsgSignature><TimeStamp>%s</TimeStamp><Nonce><![CDATA[%s]]></Nonce></xml>";
|
||||
$xml = sprintf($format, $encrypt, $signature, $timestamp, $nonce);
|
||||
}
|
||||
if ($return) return $xml;
|
||||
if ($return) {
|
||||
return $xml;
|
||||
}
|
||||
@ob_clean();
|
||||
echo $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证来自微信服务器
|
||||
* @param string $str
|
||||
* @return bool
|
||||
*/
|
||||
private function checkSignature()
|
||||
private function checkSignature($str = '')
|
||||
{
|
||||
$nonce = $this->input->get('nonce');
|
||||
$timestamp = $this->input->get('timestamp');
|
||||
$msg_signature = $this->input->get('msg_signature');
|
||||
$signature = empty($msg_signature) ? $this->input->get('signature') : $msg_signature;
|
||||
$tmpArr = [$this->config->get('token'), $timestamp, $nonce, ''];
|
||||
$nonce = $this->params->get('nonce');
|
||||
$timestamp = $this->params->get('timestamp');
|
||||
$msg_signature = $this->params->get('msg_signature');
|
||||
$signature = empty($msg_signature) ? $this->params->get('signature') : $msg_signature;
|
||||
$tmpArr = [$this->config->get('token'), $timestamp, $nonce, $str];
|
||||
sort($tmpArr, SORT_STRING);
|
||||
return sha1(implode($tmpArr)) === $signature;
|
||||
if (sha1(implode($tmpArr)) == $signature) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
@ -42,25 +40,19 @@ class BasicWeChat
|
||||
* 当前请求方法参数
|
||||
* @var array
|
||||
*/
|
||||
protected $currentMethod = [];
|
||||
private $currentMethod = [];
|
||||
|
||||
/**
|
||||
* 当前模式
|
||||
* @var bool
|
||||
*/
|
||||
protected $isTry = false;
|
||||
|
||||
/**
|
||||
* 静态缓存
|
||||
* @var static
|
||||
*/
|
||||
protected static $cache;
|
||||
private $isTry = false;
|
||||
|
||||
/**
|
||||
* 注册代替函数
|
||||
* @var string
|
||||
*/
|
||||
protected $GetAccessTokenCallback;
|
||||
private $GetAccessTokenCallback;
|
||||
|
||||
/**
|
||||
* BasicWeChat constructor.
|
||||
@ -84,19 +76,7 @@ class BasicWeChat
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态创建对象
|
||||
* @param array $config
|
||||
* @return static
|
||||
*/
|
||||
public static function instance(array $config)
|
||||
{
|
||||
$key = md5(get_called_class() . serialize($config));
|
||||
if (isset(self::$cache[$key])) return self::$cache[$key];
|
||||
return self::$cache[$key] = new static($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取访问 AccessToken
|
||||
* 获取访问accessToken
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
@ -130,25 +110,25 @@ class BasicWeChat
|
||||
|
||||
/**
|
||||
* 设置外部接口 AccessToken
|
||||
* @param string $accessToken
|
||||
* @param string $access_token
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @author 高一平 <iam@gaoyiping.com>
|
||||
*
|
||||
* 当用户使用自己的缓存驱动时,直接实例化对象后可直接设置 AccessToken
|
||||
* 当用户使用自己的缓存驱动时,直接实例化对象后可直接设置 AccessToekn
|
||||
* - 多用于分布式项目时保持 AccessToken 统一
|
||||
* - 使用此方法后就由用户来保证传入的 AccessToken 为有效 AccessToken
|
||||
* - 使用此方法后就由用户来保证传入的 AccessToekn 为有效 AccessToekn
|
||||
*/
|
||||
public function setAccessToken($accessToken)
|
||||
public function setAccessToken($access_token)
|
||||
{
|
||||
if (!is_string($accessToken)) {
|
||||
if (!is_string($access_token)) {
|
||||
throw new InvalidArgumentException("Invalid AccessToken type, need string.");
|
||||
}
|
||||
$cache = $this->config->get('appid') . '_access_token';
|
||||
Tools::setCache($cache, $this->access_token = $accessToken);
|
||||
Tools::setCache($cache, $this->access_token = $access_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理删除 AccessToken
|
||||
* 清理删除accessToken
|
||||
* @return bool
|
||||
*/
|
||||
public function delAccessToken()
|
||||
@ -162,20 +142,18 @@ class BasicWeChat
|
||||
* @param string $url 接口地址
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
protected function httpGetForJson($url)
|
||||
{
|
||||
try {
|
||||
return Tools::json2arr(Tools::get($url));
|
||||
} catch (InvalidResponseException $exception) {
|
||||
if (isset($this->currentMethod['method']) && empty($this->isTry)) {
|
||||
if (in_array($exception->getCode(), ['40014', '40001', '41001', '42001'])) {
|
||||
[$this->delAccessToken(), $this->isTry = true];
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
} catch (InvalidResponseException $e) {
|
||||
if (!$this->isTry && in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) {
|
||||
$this->delAccessToken();
|
||||
$this->isTry = true;
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
throw new InvalidResponseException($exception->getMessage(), $exception->getCode());
|
||||
throw new InvalidResponseException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,24 +161,20 @@ class BasicWeChat
|
||||
* 以POST获取接口数据并转为数组
|
||||
* @param string $url 接口地址
|
||||
* @param array $data 请求数据
|
||||
* @param bool $toJson 转换JSON
|
||||
* @param array $options 请求扩展数据
|
||||
* @param bool $buildToJson
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
protected function httpPostForJson($url, array $data, $toJson = true, array $options = [])
|
||||
protected function httpPostForJson($url, array $data, $buildToJson = true)
|
||||
{
|
||||
try {
|
||||
$options['headers'] = isset($options['headers']) ? $options['headers'] : [];
|
||||
if ($toJson) $options['headers'][] = 'Content-Type: application/json';
|
||||
return Tools::json2arr(Tools::post($url, $toJson ? Tools::arr2json($data) : $data, $options));
|
||||
} catch (InvalidResponseException $exception) {
|
||||
if (!$this->isTry && in_array($exception->getCode(), ['40014', '40001', '41001', '42001'])) {
|
||||
return Tools::json2arr(Tools::post($url, $buildToJson ? Tools::arr2json($data) : $data));
|
||||
} catch (InvalidResponseException $e) {
|
||||
if (!$this->isTry && in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) {
|
||||
[$this->delAccessToken(), $this->isTry = true];
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
throw new InvalidResponseException($exception->getMessage(), $exception->getCode());
|
||||
throw new InvalidResponseException($e->getMessage(), $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,37 +183,39 @@ class BasicWeChat
|
||||
* @param string $url 接口地址
|
||||
* @param string $method 当前接口方法
|
||||
* @param array $arguments 请求参数
|
||||
* @return string
|
||||
* @return mixed
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
protected function registerApi(&$url, $method, $arguments = [])
|
||||
{
|
||||
$this->currentMethod = ['method' => $method, 'arguments' => $arguments];
|
||||
if (empty($this->access_token)) $this->access_token = $this->getAccessToken();
|
||||
return $url = str_replace('ACCESS_TOKEN', urlencode($this->access_token), $url);
|
||||
if (empty($this->access_token)) {
|
||||
$this->access_token = $this->getAccessToken();
|
||||
}
|
||||
return $url = str_replace('ACCESS_TOKEN', $this->access_token, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口通用POST请求方法
|
||||
* @param string $url 接口URL
|
||||
* @param array $data POST提交接口参数
|
||||
* @param bool $toJson 是否转换为JSON参数
|
||||
* @param bool $isBuildJson
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function callPostApi($url, array $data, $toJson = true, array $options = [])
|
||||
public function callPostApi($url, array $data, $isBuildJson = true)
|
||||
{
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data, $toJson, $options);
|
||||
return $this->httpPostForJson($url, $data, $isBuildJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口通用GET请求方法
|
||||
* @param string $url 接口URL
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function callGetApi($url)
|
||||
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
|
||||
/**
|
||||
* 企业微信基础类
|
||||
* Class BasicWeWork
|
||||
* @package WeChat\Contracts
|
||||
*/
|
||||
class BasicWeWork extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 获取访问 AccessToken
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
if ($this->access_token) return $this->access_token;
|
||||
$ckey = $this->config->get('appid') . '_access_token';
|
||||
if ($this->access_token = Tools::getCache($ckey)) return $this->access_token;
|
||||
list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
|
||||
$result = Tools::json2arr(Tools::get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={$appid}&corpsecret={$secret}"));
|
||||
if (isset($result['access_token']) && $result['access_token']) Tools::setCache($ckey, $result['access_token'], 7000);
|
||||
return $this->access_token = $result['access_token'];
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
@ -53,7 +51,7 @@ class DataArray implements ArrayAccess
|
||||
/**
|
||||
* 获取配置项参数
|
||||
* @param string|null $offset
|
||||
* @return array|string|null|mixed
|
||||
* @return array|string|null
|
||||
*/
|
||||
public function get($offset = null)
|
||||
{
|
||||
@ -78,9 +76,7 @@ class DataArray implements ArrayAccess
|
||||
* 设置配置项值
|
||||
* @param string $offset
|
||||
* @param string|array|null|integer $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
@ -95,7 +91,6 @@ class DataArray implements ArrayAccess
|
||||
* @param string $offset
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->config[$offset]);
|
||||
@ -104,9 +99,7 @@ class DataArray implements ArrayAccess
|
||||
/**
|
||||
* 清理配置项
|
||||
* @param string|null $offset
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset = null)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
@ -119,12 +112,13 @@ class DataArray implements ArrayAccess
|
||||
/**
|
||||
* 获取配置项参数
|
||||
* @param string|null $offset
|
||||
* @return mixed
|
||||
* @return array|string|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset = null)
|
||||
{
|
||||
if (is_null($offset)) return $this->config;
|
||||
if (is_null($offset)) {
|
||||
return $this->config;
|
||||
}
|
||||
return isset($this->config[$offset]) ? $this->config[$offset] : null;
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
|
||||
/**
|
||||
* 自定义CURL文件类
|
||||
* Class MyCurlFile
|
||||
* @package WeChat\Contracts
|
||||
*/
|
||||
class MyCurlFile extends \stdClass
|
||||
{
|
||||
/**
|
||||
* 当前数据类型
|
||||
* @var string
|
||||
*/
|
||||
public $datatype = 'MY_CURL_FILE';
|
||||
|
||||
/**
|
||||
* MyCurlFile constructor.
|
||||
* @param string|array $filename
|
||||
* @param string $mimetype
|
||||
* @param string $postname
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function __construct($filename, $mimetype = '', $postname = '')
|
||||
{
|
||||
if (is_array($filename)) {
|
||||
foreach ($filename as $k => $v) $this->{$k} = $v;
|
||||
} else {
|
||||
$this->mimetype = $mimetype;
|
||||
$this->postname = $postname;
|
||||
$this->extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
if (empty($this->extension)) $this->extension = 'tmp';
|
||||
if (empty($this->mimetype)) $this->mimetype = Tools::getExtMine($this->extension);
|
||||
if (empty($this->postname)) $this->postname = pathinfo($filename, PATHINFO_BASENAME);
|
||||
$this->content = base64_encode(file_get_contents($filename));
|
||||
$this->tempname = md5($this->content) . ".{$this->extension}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传信息
|
||||
* @return \CURLFile|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$this->filename = Tools::pushFile($this->tempname, base64_decode($this->content));
|
||||
if (class_exists('CURLFile')) {
|
||||
return new \CURLFile($this->filename, $this->mimetype, $this->postname);
|
||||
} else {
|
||||
return "@{$this->tempname};filename={$this->postname};type={$this->mimetype}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用销毁函数清理缓存文件
|
||||
* 提前删除过期因此放到了网络请求之后
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// Tools::delCache($this->tempname);
|
||||
}
|
||||
|
||||
}
|
@ -3,16 +3,57 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Prpcrypt;
|
||||
/**
|
||||
* PKCS7算法 - 加解密
|
||||
* Class PKCS7Encoder
|
||||
*/
|
||||
class PKCS7Encoder
|
||||
{
|
||||
|
||||
public static $blockSize = 32;
|
||||
|
||||
/**
|
||||
* 对需要加密的明文进行填充补位
|
||||
* @param string $text 需要进行填充补位操作的明文
|
||||
* @return string 补齐明文字符串
|
||||
*/
|
||||
function encode($text)
|
||||
{
|
||||
$amount_to_pad = PKCS7Encoder::$blockSize - (strlen($text) % PKCS7Encoder::$blockSize);
|
||||
if ($amount_to_pad == 0) {
|
||||
$amount_to_pad = PKCS7Encoder::$blockSize;
|
||||
}
|
||||
list($pad_chr, $tmp) = [chr($amount_to_pad), ''];
|
||||
for ($index = 0; $index < $amount_to_pad; $index++) {
|
||||
$tmp .= $pad_chr;
|
||||
}
|
||||
return $text . $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对解密后的明文进行补位删除
|
||||
* @param string $text 解密后的明文
|
||||
* @return string 删除填充补位后的明文
|
||||
*/
|
||||
function decode($text)
|
||||
{
|
||||
$pad = ord(substr($text, -1));
|
||||
if ($pad < 1 || $pad > PKCS7Encoder::$blockSize) {
|
||||
$pad = 0;
|
||||
}
|
||||
return substr($text, 0, strlen($text) - $pad);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号消息 - 加解密
|
||||
@ -47,7 +88,7 @@ class Prpcrypt
|
||||
$text = $pkcEncoder->encode($random . pack("N", strlen($text)) . $text . $appid);
|
||||
$encrypted = openssl_encrypt($text, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
|
||||
return [ErrorCode::$OK, $encrypted];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return [ErrorCode::$EncryptAESError, null];
|
||||
}
|
||||
}
|
||||
@ -62,7 +103,7 @@ class Prpcrypt
|
||||
try {
|
||||
$iv = substr($this->key, 0, 16);
|
||||
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return [ErrorCode::$DecryptAESError, null];
|
||||
}
|
||||
try {
|
||||
@ -75,7 +116,7 @@ class Prpcrypt
|
||||
$len_list = unpack("N", substr($content, 0, 4));
|
||||
$xml_len = $len_list[1];
|
||||
return [0, substr($content, 4, $xml_len), substr($content, $xml_len + 4)];
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return [ErrorCode::$IllegalBuffer, null];
|
||||
}
|
||||
}
|
||||
@ -96,3 +137,53 @@ class Prpcrypt
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅用作类内部使用
|
||||
* 不用于官方API接口的errCode码
|
||||
* Class ErrorCode
|
||||
*/
|
||||
class ErrorCode
|
||||
{
|
||||
|
||||
public static $OK = 0;
|
||||
public static $ParseXmlError = 40002;
|
||||
public static $IllegalAesKey = 40004;
|
||||
public static $IllegalBuffer = 40008;
|
||||
public static $EncryptAESError = 40006;
|
||||
public static $DecryptAESError = 40007;
|
||||
public static $EncodeBase64Error = 40009;
|
||||
public static $DecodeBase64Error = 40010;
|
||||
public static $GenReturnXmlError = 40011;
|
||||
public static $ValidateAppidError = 40005;
|
||||
public static $ComputeSignatureError = 40003;
|
||||
public static $ValidateSignatureError = 40001;
|
||||
public static $errCode = [
|
||||
'0' => '处理成功',
|
||||
'40001' => '校验签名失败',
|
||||
'40002' => '解析xml失败',
|
||||
'40003' => '计算签名失败',
|
||||
'40004' => '不合法的AESKey',
|
||||
'40005' => '校验AppID失败',
|
||||
'40006' => 'AES加密失败',
|
||||
'40007' => 'AES解密失败',
|
||||
'40008' => '公众平台发送的xml不合法',
|
||||
'40009' => 'Base64编码失败',
|
||||
'40010' => 'Base64解码失败',
|
||||
'40011' => '公众帐号生成回包xml失败',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取错误消息内容
|
||||
* @param string $code 错误代码
|
||||
* @return bool
|
||||
*/
|
||||
public static function getErrText($code)
|
||||
{
|
||||
if (isset(self::$errCode[$code])) {
|
||||
return self::$errCode[$code];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
@ -20,32 +18,6 @@ use WeChat\Exceptions\InvalidArgumentException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
// =====================================================
|
||||
// 配置缓存处理函数 ( 适配其他环境 )
|
||||
// -----------------------------------------------------
|
||||
// 数据缓存 (set|get|del) 操作可以将缓存写到任意位置或Redis
|
||||
// 文件缓存 (put) 只能写在本地服务器,还需要返回可读的文件路径
|
||||
// 未配置自定义缓存处理机制时,默认在 cache_path 写入文件缓存
|
||||
// // =====================================================
|
||||
// \WeChat\Contracts\Tools::$cache_callable = [
|
||||
// 'set' => function ($name, $value, $expired = 360) {
|
||||
// var_dump(func_get_args());
|
||||
// return $value;
|
||||
// },
|
||||
// 'get' => function ($name) {
|
||||
// var_dump(func_get_args());
|
||||
// return $value;
|
||||
// },
|
||||
// 'del' => function ($name) {
|
||||
// var_dump(func_get_args());
|
||||
// return true;
|
||||
// },
|
||||
// 'put' => function ($name) {
|
||||
// var_dump(func_get_args());
|
||||
// return $filePath;
|
||||
// },
|
||||
// ];
|
||||
|
||||
/**
|
||||
* 网络请求支持
|
||||
* Class Tools
|
||||
@ -59,22 +31,6 @@ class Tools
|
||||
*/
|
||||
public static $cache_path = null;
|
||||
|
||||
/**
|
||||
* 缓存读写配置
|
||||
* @var array
|
||||
*/
|
||||
public static $cache_callable = [
|
||||
'set' => null, // 写入缓存 ($name,$value='',$expired=3600):string
|
||||
'get' => null, // 获取缓存 ($name):mixed|null
|
||||
'del' => null, // 删除缓存 ($name):boolean
|
||||
'put' => null, // 写入文件 ($name,$content):string
|
||||
];
|
||||
|
||||
/**
|
||||
* 网络缓存
|
||||
* @var array
|
||||
*/
|
||||
private static $cache_curl = [];
|
||||
|
||||
/**
|
||||
* 产生随机字符串
|
||||
@ -91,35 +47,13 @@ class Tools
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取输入对象
|
||||
* @return string
|
||||
*/
|
||||
public static function getRawInput()
|
||||
{
|
||||
if (empty($GLOBALS['HTTP_RAW_POST_DATA'])) {
|
||||
return file_get_contents('php://input');
|
||||
} else {
|
||||
return $GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置输入内容
|
||||
* @param string $rawInput
|
||||
* @return void
|
||||
*/
|
||||
public static function setRawInput($rawInput)
|
||||
{
|
||||
$GLOBALS['HTTP_RAW_POST_DATA'] = $rawInput;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件后缀获取文件类型
|
||||
* @param string|array $ext 文件后缀
|
||||
* 根据文件后缀获取文件MINE
|
||||
* @param array $ext 文件后缀
|
||||
* @param array $mine 文件后缀MINE信息
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public static function getExtMine($ext, $mine = [])
|
||||
{
|
||||
@ -131,9 +65,9 @@ class Tools
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有文件扩展的类型
|
||||
* 获取所有文件扩展的mine
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
private static function getMines()
|
||||
{
|
||||
@ -141,7 +75,9 @@ class Tools
|
||||
if (empty($mines)) {
|
||||
$content = file_get_contents('http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
|
||||
preg_match_all('#^([^\s]{2,}?)\s+(.+?)$#ism', $content, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) foreach (explode(" ", $match[2]) as $ext) $mines[$ext] = $match[1];
|
||||
foreach ($matches as $match) foreach (explode(" ", $match[2]) as $ext) {
|
||||
$mines[$ext] = $match[1];
|
||||
}
|
||||
self::setCache('all_ext_mine', $mines);
|
||||
}
|
||||
return $mines;
|
||||
@ -149,24 +85,20 @@ class Tools
|
||||
|
||||
/**
|
||||
* 创建CURL文件对象
|
||||
* @param mixed $filename
|
||||
* @param $filename
|
||||
* @param string $mimetype
|
||||
* @param string $postname
|
||||
* @return \CURLFile|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public static function createCurlFile($filename, $mimetype = null, $postname = null)
|
||||
{
|
||||
if (is_string($filename) && file_exists($filename)) {
|
||||
if (is_null($postname)) $postname = basename($filename);
|
||||
if (is_null($mimetype)) $mimetype = self::getExtMine(pathinfo($filename, 4));
|
||||
if (class_exists('CURLFile')) {
|
||||
return new \CURLFile($filename, $mimetype, $postname);
|
||||
} else {
|
||||
return "@{$filename};filename={$postname};type={$mimetype}";
|
||||
}
|
||||
is_null($postname) && $postname = basename($filename);
|
||||
is_null($mimetype) && $mimetype = self::getExtMine(pathinfo($filename, 4));
|
||||
if (function_exists('curl_file_create')) {
|
||||
return curl_file_create($filename, $mimetype, $postname);
|
||||
}
|
||||
return $filename;
|
||||
return "@{$filename};filename={$postname};type={$mimetype}";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -209,105 +141,29 @@ class Tools
|
||||
*/
|
||||
public static function xml2arr($xml)
|
||||
{
|
||||
if (PHP_VERSION_ID < 80000) {
|
||||
$backup = libxml_disable_entity_loader(true);
|
||||
$data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
libxml_disable_entity_loader($backup);
|
||||
} else {
|
||||
$data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
}
|
||||
return json_decode(json_encode($data), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析XML文本内容
|
||||
* @param string $xml
|
||||
* @return array|false
|
||||
*/
|
||||
public static function xml3arr($xml)
|
||||
{
|
||||
$state = xml_parse($parser = xml_parser_create(), $xml, true);
|
||||
return xml_parser_free($parser) && $state ? self::xml2arr($xml) : false;
|
||||
$entity = libxml_disable_entity_loader(true);
|
||||
$data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
libxml_disable_entity_loader($entity);
|
||||
return json_decode(self::arr2json($data), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转xml内容
|
||||
* @param array $data
|
||||
* @return null|string
|
||||
* @return null|string|string
|
||||
*/
|
||||
public static function arr2json($data)
|
||||
{
|
||||
$json = json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
return $json === '[]' ? '{}' : $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组对象Emoji编译处理
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public static function buildEnEmojiData(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$data[$key] = self::buildEnEmojiData($value);
|
||||
} elseif (is_string($value)) {
|
||||
$data[$key] = self::emojiEncode($value);
|
||||
} else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组对象Emoji反解析处理
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public static function buildDeEmojiData(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$data[$key] = self::buildDeEmojiData($value);
|
||||
} elseif (is_string($value)) {
|
||||
$data[$key] = self::emojiDecode($value);
|
||||
} else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emoji原形转换为String
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
public static function emojiEncode($content)
|
||||
{
|
||||
return json_decode(preg_replace_callback("/(\\\u[ed][0-9a-f]{3})/i", function ($string) {
|
||||
return addslashes($string[0]);
|
||||
}, json_encode($content)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Emoji字符串转换为原形
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
public static function emojiDecode($content)
|
||||
{
|
||||
return json_decode(preg_replace_callback('/\\\\\\\\/i', function () {
|
||||
return '\\';
|
||||
}, json_encode($content)));
|
||||
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function ($matches) {
|
||||
return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");
|
||||
}, ($jsonData = json_encode($data)) == '[]' ? '{}' : $jsonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析JSON内容到数组
|
||||
* @param string $json
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public static function json2arr($json)
|
||||
{
|
||||
@ -326,8 +182,7 @@ class Tools
|
||||
* @param string $url 访问URL
|
||||
* @param array $query GET数
|
||||
* @param array $options
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function get($url, $query = [], $options = [])
|
||||
{
|
||||
@ -340,8 +195,7 @@ class Tools
|
||||
* @param string $url 访问URL
|
||||
* @param array $data POST数据
|
||||
* @param array $options
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function post($url, $data = [], $options = [])
|
||||
{
|
||||
@ -354,10 +208,9 @@ class Tools
|
||||
* @param string $method 请求方法
|
||||
* @param string $url 请求方法
|
||||
* @param array $options 请求参数[headers,data,ssl_cer,ssl_key]
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function doRequest($method, $url, $options = [])
|
||||
protected static function doRequest($method, $url, $options = [])
|
||||
{
|
||||
$curl = curl_init();
|
||||
// GET参数设置
|
||||
@ -371,63 +224,34 @@ class Tools
|
||||
// POST数据设置
|
||||
if (strtolower($method) === 'post') {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, self::_buildHttpData($options['data']));
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $options['data']);
|
||||
}
|
||||
// 证书文件设置
|
||||
if (!empty($options['ssl_cer'])) if (file_exists($options['ssl_cer'])) {
|
||||
curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM');
|
||||
curl_setopt($curl, CURLOPT_SSLCERT, $options['ssl_cer']);
|
||||
} else throw new InvalidArgumentException("Certificate files that do not exist. --- [ssl_cer]");
|
||||
if (!empty($options['ssl_cer'])) {
|
||||
if (file_exists($options['ssl_cer'])) {
|
||||
curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM');
|
||||
curl_setopt($curl, CURLOPT_SSLCERT, $options['ssl_cer']);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Certificate files that do not exist. --- [ssl_cer]");
|
||||
}
|
||||
}
|
||||
// 证书文件设置
|
||||
if (!empty($options['ssl_key'])) if (file_exists($options['ssl_key'])) {
|
||||
curl_setopt($curl, CURLOPT_SSLKEYTYPE, 'PEM');
|
||||
curl_setopt($curl, CURLOPT_SSLKEY, $options['ssl_key']);
|
||||
} else throw new InvalidArgumentException("Certificate files that do not exist. --- [ssl_key]");
|
||||
if (!empty($options['ssl_key'])) {
|
||||
if (file_exists($options['ssl_key'])) {
|
||||
curl_setopt($curl, CURLOPT_SSLKEYTYPE, 'PEM');
|
||||
curl_setopt($curl, CURLOPT_SSLKEY, $options['ssl_key']);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Certificate files that do not exist. --- [ssl_key]");
|
||||
}
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$content = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
// 清理 CURL 缓存文件
|
||||
if (!empty(self::$cache_curl)) foreach (self::$cache_curl as $key => $file) {
|
||||
Tools::delCache($file);
|
||||
unset(self::$cache_curl[$key]);
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST数据过滤处理
|
||||
* @param array $data 需要处理的数据
|
||||
* @param boolean $build 是否编译数据
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
private static function _buildHttpData($data, $build = true)
|
||||
{
|
||||
if (!is_array($data)) return $data;
|
||||
foreach ($data as $key => $value) if ($value instanceof \CURLFile) {
|
||||
$build = false;
|
||||
} elseif (is_object($value) && isset($value->datatype) && $value->datatype === 'MY_CURL_FILE') {
|
||||
$build = false;
|
||||
$mycurl = new MyCurlFile((array)$value);
|
||||
$data[$key] = $mycurl->get();
|
||||
self::$cache_curl[] = $mycurl->tempname;
|
||||
} elseif (is_array($value) && isset($value['datatype']) && $value['datatype'] === 'MY_CURL_FILE') {
|
||||
$build = false;
|
||||
$mycurl = new MyCurlFile($value);
|
||||
$data[$key] = $mycurl->get();
|
||||
self::$cache_curl[] = $mycurl->tempname;
|
||||
} elseif (is_string($value) && class_exists('CURLFile', false) && stripos($value, '@') === 0) {
|
||||
if (($filename = realpath(trim($value, '@'))) && file_exists($filename)) {
|
||||
$build = false;
|
||||
$data[$key] = self::createCurlFile($filename);
|
||||
}
|
||||
}
|
||||
return $build ? http_build_query($data) : $data;
|
||||
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
|
||||
return (intval($status["http_code"]) === 200) ? $content : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -435,17 +259,12 @@ class Tools
|
||||
* @param string $name 文件名称
|
||||
* @param string $content 文件内容
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public static function pushFile($name, $content)
|
||||
{
|
||||
if (is_callable(self::$cache_callable['put'])) {
|
||||
return call_user_func_array(self::$cache_callable['put'], func_get_args());
|
||||
}
|
||||
$file = self::_getCacheName($name);
|
||||
if (!file_put_contents($file, $content)) {
|
||||
throw new LocalCacheException('local file write error.', '0');
|
||||
}
|
||||
$file = self::getCacheName($name);
|
||||
if (!file_put_contents($file, $content)) throw new LocalCacheException('local file write error.', '0');
|
||||
return $file;
|
||||
}
|
||||
|
||||
@ -455,18 +274,13 @@ class Tools
|
||||
* @param string $value 缓存内容
|
||||
* @param int $expired 缓存时间(0表示永久缓存)
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public static function setCache($name, $value = '', $expired = 3600)
|
||||
{
|
||||
if (is_callable(self::$cache_callable['set'])) {
|
||||
return call_user_func_array(self::$cache_callable['set'], func_get_args());
|
||||
}
|
||||
$file = self::_getCacheName($name);
|
||||
$data = ['name' => $name, 'value' => $value, 'expired' => time() + intval($expired)];
|
||||
if (!file_put_contents($file, serialize($data))) {
|
||||
throw new LocalCacheException('local cache error.', '0');
|
||||
}
|
||||
$file = self::getCacheName($name);
|
||||
$content = serialize(['name' => $name, 'value' => $value, 'expired' => time() + intval($expired)]);
|
||||
if (!file_put_contents($file, $content)) throw new LocalCacheException('local cache error.', '0');
|
||||
return $file;
|
||||
}
|
||||
|
||||
@ -477,11 +291,8 @@ class Tools
|
||||
*/
|
||||
public static function getCache($name)
|
||||
{
|
||||
if (is_callable(self::$cache_callable['get'])) {
|
||||
return call_user_func_array(self::$cache_callable['get'], func_get_args());
|
||||
}
|
||||
$file = self::_getCacheName($name);
|
||||
if (file_exists($file) && is_file($file) && ($content = file_get_contents($file))) {
|
||||
$file = self::getCacheName($name);
|
||||
if (file_exists($file) && ($content = file_get_contents($file))) {
|
||||
$data = unserialize($content);
|
||||
if (isset($data['expired']) && (intval($data['expired']) === 0 || intval($data['expired']) >= time())) {
|
||||
return $data['value'];
|
||||
@ -494,15 +305,12 @@ class Tools
|
||||
/**
|
||||
* 移除缓存文件
|
||||
* @param string $name 缓存名称
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public static function delCache($name)
|
||||
{
|
||||
if (is_callable(self::$cache_callable['del'])) {
|
||||
return call_user_func_array(self::$cache_callable['del'], func_get_args());
|
||||
}
|
||||
$file = self::_getCacheName($name);
|
||||
return !file_exists($file) || @unlink($file);
|
||||
$file = self::getCacheName($name);
|
||||
return file_exists($file) ? unlink($file) : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -510,7 +318,7 @@ class Tools
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private static function _getCacheName($name)
|
||||
private static function getCacheName($name)
|
||||
{
|
||||
if (empty(self::$cache_path)) {
|
||||
self::$cache_path = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR;
|
||||
@ -519,4 +327,4 @@ class Tools
|
||||
file_exists(self::$cache_path) || mkdir(self::$cache_path, 0755, true);
|
||||
return self::$cache_path . $name;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -36,49 +34,56 @@ class Custom extends BasicWeChat
|
||||
*/
|
||||
public function addAccount($kf_account, $nickname)
|
||||
{
|
||||
$data = ['kf_account' => $kf_account, 'nickname' => $nickname];
|
||||
$url = "https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['kf_account' => $kf_account, 'nickname' => $nickname]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客服帐号
|
||||
* @param string $kfAccount 客服账号
|
||||
* @param string $kf_account 客服账号
|
||||
* @param string $nickname 客服昵称
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateAccount($kfAccount, $nickname)
|
||||
public function updateAccount($kf_account, $nickname)
|
||||
{
|
||||
$data = ['kf_account' => $kf_account, 'nickname' => $nickname];
|
||||
$url = "https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['kf_account' => $kfAccount, 'nickname' => $nickname]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客服帐号
|
||||
* @param string $kfAccount 客服账号
|
||||
* @param string $kf_account 客服账号
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteAccount($kfAccount)
|
||||
public function deleteAccount($kf_account)
|
||||
{
|
||||
$data = ['kf_account' => $kf_account];
|
||||
$url = "https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['kf_account' => $kfAccount]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请绑定客服帐号
|
||||
* @param string $kfAccount 完整客服帐号,格式为:帐号前缀@公众号微信号
|
||||
* @param string $kf_account 完整客服帐号,格式为:帐号前缀@公众号微信号
|
||||
* @param string $invite_wx 接收绑定邀请的客服微信号
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function inviteWorker($kfAccount, $invite_wx)
|
||||
public function inviteworker($kf_account, $invite_wx)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['kf_account' => $kfAccount, 'invite_wx' => $invite_wx]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['kf_account' => $kf_account, 'invite_wx' => $invite_wx]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +95,8 @@ class Custom extends BasicWeChat
|
||||
public function getAccountList()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,8 +109,9 @@ class Custom extends BasicWeChat
|
||||
*/
|
||||
public function uploadHeadimg($kf_account, $image)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account={$kf_account}";
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($image)], false);
|
||||
$url = "http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account={$kf_account}";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($image)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +124,8 @@ class Custom extends BasicWeChat
|
||||
public function send(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +139,8 @@ class Custom extends BasicWeChat
|
||||
public function typing($openid, $command = 'Typing')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['touser' => $openid, 'command' => $command]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['touser' => $openid, 'command' => $command]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,7 +153,8 @@ class Custom extends BasicWeChat
|
||||
public function massSendAll(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +167,8 @@ class Custom extends BasicWeChat
|
||||
public function massSend(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +184,8 @@ class Custom extends BasicWeChat
|
||||
$data = ['msg_id' => $msg_id];
|
||||
is_null($article_idx) || $data['article_idx'] = $article_idx;
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,20 +198,22 @@ class Custom extends BasicWeChat
|
||||
public function massPreview(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询群发消息发送状态【订阅号与服务号认证后均可用】
|
||||
* @param integer $msgId 群发消息后返回的消息id
|
||||
* @param integer $msg_id 群发消息后返回的消息id
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function massGet($msgId)
|
||||
public function massGet($msg_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['msg_id' => $msgId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['msg_id' => $msg_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +225,8 @@ class Custom extends BasicWeChat
|
||||
public function massGetSeed()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, []);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, []);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,6 +239,9 @@ class Custom extends BasicWeChat
|
||||
public function massSetSeed($speed)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/set?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['speed' => $speed]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['speed' => $speed]);
|
||||
}
|
||||
|
||||
|
||||
}
|
124
WeChat/Draft.php
124
WeChat/Draft.php
@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 微信草稿箱管理
|
||||
* Class Draft
|
||||
* @author taoxin
|
||||
* @package WeChat
|
||||
*/
|
||||
class Draft extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 新建草稿
|
||||
* @param $articles
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function add($articles)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['articles' => $articles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取草稿
|
||||
* @param string $mediaId
|
||||
* @param string $outType 返回处理函数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get($mediaId, $outType = null)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['media_id' => $mediaId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除草稿
|
||||
* @param string $mediaId
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delete($mediaId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['media_id' => $mediaId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图文素材
|
||||
* @param array $data 文件名称
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addNews($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改草稿
|
||||
* @param string $media_id 要修改的图文消息的id
|
||||
* @param int $index 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为0
|
||||
* @param $articles
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function update($media_id, $index, $articles)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/update?access_token=ACCESS_TOKEN";
|
||||
$data = ['media_id' => $media_id, 'index' => $index, 'articles' => $articles];
|
||||
return $this->callPostApi($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取草稿总数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/count?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取草稿列表
|
||||
* @param int $offset 从全部素材的该偏移位置开始返回,0表示从第一个素材返回
|
||||
* @param int $count 返回素材的数量,取值在1到20之间
|
||||
* @param int $noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function batchGet($offset = 0, $count = 20, $noContent = 0)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['no_content' => $noContent, 'offset' => $offset, 'count' => $count]);
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 发布能力
|
||||
* Class Freepublish
|
||||
* @author taoxin
|
||||
* @package WeChat
|
||||
*/
|
||||
class Freepublish extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 发布接口
|
||||
* 开发者需要先将图文素材以草稿的形式保存(见“草稿箱/新建草稿”,如需从已保存的草稿中选择,见“草稿箱/获取草稿列表”)
|
||||
* @param mixed $mediaId 选择要发布的草稿的media_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function submit($mediaId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/freepublish/submit?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['media_id' => $mediaId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布状态轮询接口
|
||||
* @param mixed $publishId
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get($publishId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/freepublish/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['publish_id' => $publishId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除发布
|
||||
* 发布成功之后,随时可以通过该接口删除。此操作不可逆,请谨慎操作。
|
||||
* @param mixed $articleId 成功发布时返回的 article_id
|
||||
* @param int $index 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delete($articleId, $index = 0)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/freepublish/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['article_id' => $articleId, 'index' => $index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 article_id 获取已发布文章
|
||||
* @param mixed $articleId 要获取的草稿的article_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getArticle($articleId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/freepublish/getarticle?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['article_id' => $articleId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成功发布列表
|
||||
* @param int $offset 从全部素材的该偏移位置开始返回,0表示从第一个素材返回
|
||||
* @param int $count 返回素材的数量,取值在1到20之间
|
||||
* @param int $noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function batchGet($offset = 0, $count = 20, $noContent = 0)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['no_content' => $noContent, 'offset' => $offset, 'count' => $count]);
|
||||
}
|
||||
}
|
@ -3,19 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
@ -29,38 +28,15 @@ class Limit extends BasicWeChat
|
||||
/**
|
||||
* 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function clearQuota()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['appid' => $this->config->get('appid')]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络检测
|
||||
* @param string $action 执行的检测动作
|
||||
* @param string $operator 指定平台从某个运营商进行检测
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function ping($action = 'all', $operator = 'DEFAULT')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/callback/check?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['action' => $action, 'check_operator' => $operator]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信服务器IP地址
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCallbackIp()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN';
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
}
|
@ -3,21 +3,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
/**
|
||||
@ -32,8 +30,8 @@ class Media extends BasicWeChat
|
||||
* @param string $filename 文件名称
|
||||
* @param string $type 媒体文件类型(image|voice|video|thumb)
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function add($filename, $type = 'image')
|
||||
{
|
||||
@ -41,7 +39,8 @@ class Media extends BasicWeChat
|
||||
throw new InvalidResponseException('Invalid Media Type.', '0');
|
||||
}
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type={$type}";
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,20 +48,15 @@ class Media extends BasicWeChat
|
||||
* @param string $media_id
|
||||
* @param string $outType 返回处理函数
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function get($media_id, $outType = null)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id={$media_id}";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
if ($outType == 'url') return $url;
|
||||
$result = Tools::get($url);
|
||||
if (is_array($json = json_decode($result, true))) {
|
||||
if (!$this->isTry && isset($json['errcode']) && in_array($json['errcode'], ['40014', '40001', '41001', '42001'])) {
|
||||
[$this->delAccessToken(), $this->isTry = true];
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
if (json_decode($result)) {
|
||||
return Tools::json2arr($result);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
@ -72,13 +66,14 @@ class Media extends BasicWeChat
|
||||
* 新增图文素材
|
||||
* @param array $data 文件名称
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function addNews($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,36 +82,39 @@ class Media extends BasicWeChat
|
||||
* @param int $index 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为0
|
||||
* @param array $news 文章内容
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function updateNews($media_id, $index, $news)
|
||||
{
|
||||
$data = ['media_id' => $media_id, 'index' => $index, 'articles' => $news];
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['media_id' => $media_id, 'index' => $index, 'articles' => $news]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图文消息内的图片获取URL
|
||||
* @param mixed $filename
|
||||
* @param string $filename
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function uploadImg($filename)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增其他类型永久素材
|
||||
* @param mixed $filename 文件名称
|
||||
* @param string $filename 文件名称
|
||||
* @param string $type 媒体文件类型(image|voice|video|thumb)
|
||||
* @param array $description 包含素材的描述信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function addMaterial($filename, $type = 'image', $description = [])
|
||||
{
|
||||
@ -124,7 +122,8 @@ class Media extends BasicWeChat
|
||||
throw new InvalidResponseException('Invalid Media Type.', '0');
|
||||
}
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type={$type}";
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::arr2json($description)], false);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::arr2json($description)], false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,20 +131,15 @@ class Media extends BasicWeChat
|
||||
* @param string $media_id
|
||||
* @param null|string $outType 输出类型
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function getMaterial($media_id, $outType = null)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
if ($outType == 'url') return $url;
|
||||
$result = Tools::post($url, ['media_id' => $media_id]);
|
||||
if (is_array($json = json_decode($result, true))) {
|
||||
if (!$this->isTry && isset($json['errcode']) && in_array($json['errcode'], ['40014', '40001', '41001', '42001'])) {
|
||||
[$this->delAccessToken(), $this->isTry = true];
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
if (json_decode($result)) {
|
||||
return Tools::json2arr($result);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
@ -153,27 +147,29 @@ class Media extends BasicWeChat
|
||||
|
||||
/**
|
||||
* 删除永久素材
|
||||
* @param string $mediaId
|
||||
* @param string $media_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function delMaterial($mediaId)
|
||||
public function delMaterial($media_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN";
|
||||
return $this->httpPostForJson($url, ['media_id' => $mediaId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media_id' => $media_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取素材总数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function getMaterialCount()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,8 +178,8 @@ class Media extends BasicWeChat
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function batchGetMaterial($type = 'image', $offset = 0, $count = 20)
|
||||
{
|
||||
@ -191,6 +187,7 @@ class Media extends BasicWeChat
|
||||
throw new InvalidResponseException('Invalid Media Type.', '0');
|
||||
}
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['type' => $type, 'offset' => $offset, 'count' => $count]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['type' => $type, 'offset' => $offset, 'count' => $count]);
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -29,76 +27,83 @@ class Menu extends BasicWeChat
|
||||
/**
|
||||
* 自定义菜单查询接口
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义菜单删除接口
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义菜单创建
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建个性化菜单
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addConditional(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除个性化菜单
|
||||
* @param string $menuid
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delConditional($menuid)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['menuid' => $menuid]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['menuid' => $menuid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试个性化菜单匹配结果
|
||||
* @param string $openid
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function tryConditional($openid)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['user_id' => $openid]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['user_id' => $openid]);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -42,16 +40,14 @@ class Oauth extends BasicWeChat
|
||||
|
||||
/**
|
||||
* 通过 code 获取 AccessToken 和 openid
|
||||
* @param string $code 授权Code值,不传则取GET参数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @return bool|array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getOauthAccessToken($code = '')
|
||||
public function getOauthAccessToken()
|
||||
{
|
||||
$appid = $this->config->get('appid');
|
||||
$appsecret = $this->config->get('appsecret');
|
||||
$code = $code ? $code : (isset($_GET['code']) ? $_GET['code'] : '');
|
||||
$code = isset($_GET['code']) ? $_GET['code'] : '';
|
||||
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code";
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
@ -59,9 +55,8 @@ class Oauth extends BasicWeChat
|
||||
/**
|
||||
* 刷新AccessToken并续期
|
||||
* @param string $refresh_token
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @return bool|array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getOauthRefreshToken($refresh_token)
|
||||
{
|
||||
@ -72,30 +67,29 @@ class Oauth extends BasicWeChat
|
||||
|
||||
/**
|
||||
* 检验授权凭证(access_token)是否有效
|
||||
* @param string $accessToken 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
|
||||
* @param string $access_token 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
|
||||
* @param string $openid 用户的唯一标识
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function checkOauthAccessToken($accessToken, $openid)
|
||||
public function checkOauthAccessToken($access_token, $openid)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/sns/auth?access_token={$accessToken}&openid={$openid}";
|
||||
$url = "https://api.weixin.qq.com/sns/auth?access_token={$access_token}&openid={$openid}";
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取用户信息(需scope为 snsapi_userinfo)
|
||||
* @param string $accessToken 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
|
||||
* @param string $access_token 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
|
||||
* @param string $openid 用户的唯一标识
|
||||
* @param string $lang 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getUserInfo($accessToken, $openid, $lang = 'zh_CN')
|
||||
public function getUserInfo($access_token, $openid, $lang = 'zh_CN')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/sns/userinfo?access_token={$accessToken}&openid={$openid}&lang={$lang}";
|
||||
$url = "https://api.weixin.qq.com/sns/userinfo?access_token={$access_token}&openid={$openid}&lang={$lang}";
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
}
|
||||
|
122
WeChat/Pay.php
122
WeChat/Pay.php
@ -3,20 +3,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WePay\Bill;
|
||||
use WePay\Order;
|
||||
use WePay\Refund;
|
||||
@ -28,32 +27,21 @@ use WePay\TransfersBank;
|
||||
* Class Pay
|
||||
* @package WeChat\Contracts
|
||||
*/
|
||||
class Pay extends BasicWePay
|
||||
class Pay extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 统一下单
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function createOrder(array $options)
|
||||
{
|
||||
return Order::instance($this->config->get())->create($options);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->create($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷卡支付
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createMicropay($options)
|
||||
{
|
||||
return Order::instance($this->config->get())->micropay($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建JsApi及H5支付参数
|
||||
@ -62,17 +50,8 @@ class Pay extends BasicWePay
|
||||
*/
|
||||
public function createParamsForJsApi($prepay_id)
|
||||
{
|
||||
return Order::instance($this->config->get())->jsapiParams($prepay_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取APP支付参数
|
||||
* @param string $prepay_id 统一下单预支付码
|
||||
* @return array
|
||||
*/
|
||||
public function createParamsForApp($prepay_id)
|
||||
{
|
||||
return Order::instance($this->config->get())->appParams($prepay_id);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->jsapiParams($prepay_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,79 +61,80 @@ class Pay extends BasicWePay
|
||||
*/
|
||||
public function createParamsForRuleQrc($product_id)
|
||||
{
|
||||
return Order::instance($this->config->get())->qrcParams($product_id);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->qrcParams($product_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function queryOrder(array $options)
|
||||
{
|
||||
return Order::instance($this->config->get())->query($options);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->query($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭订单
|
||||
* @param string $out_trade_no 商户订单号
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function closeOrder($out_trade_no)
|
||||
{
|
||||
return Order::instance($this->config->get())->close($out_trade_no);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->close($out_trade_no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function createRefund(array $options)
|
||||
{
|
||||
return Refund::instance($this->config->get())->create($options);
|
||||
$pay = new Refund($this->config->get());
|
||||
return $pay->create($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退款
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function queryRefund(array $options)
|
||||
{
|
||||
return Refund::instance($this->config->get())->query($options);
|
||||
$pay = new Refund($this->config->get());
|
||||
return $pay->query($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交易保障
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function report(array $options)
|
||||
{
|
||||
return Order::instance($this->config->get())->report($options);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->report($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权码查询openid
|
||||
* @param string $authCode 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function queryAuthCode($authCode)
|
||||
{
|
||||
return Order::instance($this->config->get())->queryAuthCode($authCode);
|
||||
$pay = new Order($this->config->get());
|
||||
return $pay->queryAuthCode($authCode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,72 +142,74 @@ class Pay extends BasicWePay
|
||||
* @param array $options 静音参数
|
||||
* @param null|string $outType 输出类型
|
||||
* @return bool|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function billDownload(array $options, $outType = null)
|
||||
{
|
||||
return Bill::instance($this->config->get())->download($options, $outType);
|
||||
$pay = new Bill($this->config->get());
|
||||
return $pay->download($options, $outType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉取订单评价数据
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function billCommtent(array $options)
|
||||
{
|
||||
return Bill::instance($this->config->get())->comment($options);
|
||||
$pay = new Bill($this->config->get());
|
||||
return $pay->commtent($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业付款到零钱
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function createTransfers(array $options)
|
||||
{
|
||||
return Transfers::instance($this->config->get())->create($options);
|
||||
$pay = new Transfers($this->config->get());
|
||||
return $pay->create($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询企业付款到零钱
|
||||
* @param string $partner_trade_no 商户调用企业付款API时使用的商户订单号
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function queryTransfers($partner_trade_no)
|
||||
{
|
||||
return Transfers::instance($this->config->get())->query($partner_trade_no);
|
||||
$pay = new Transfers($this->config->get());
|
||||
return $pay->query($partner_trade_no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业付款到银行卡
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidDecryptException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function createTransfersBank(array $options)
|
||||
{
|
||||
return TransfersBank::instance($this->config->get())->create($options);
|
||||
$pay = new TransfersBank($this->config->get());
|
||||
return $pay->create($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户企业付款到银行卡操作进行结果查询
|
||||
* @param string $partner_trade_no 商户订单号,需保持唯一
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function queryTransFresBank($partner_trade_no)
|
||||
{
|
||||
return TransfersBank::instance($this->config->get())->query($partner_trade_no);
|
||||
$pay = new TransfersBank($this->config->get());
|
||||
return $pay->query($partner_trade_no);
|
||||
}
|
||||
}
|
@ -3,19 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
@ -31,14 +30,15 @@ class Product extends BasicWeChat
|
||||
* @param string $keystr 商品编码内容
|
||||
* @param string $status 设置发布状态。on为提交审核,off为取消发布
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function modStatus($keystandard, $keystr, $status = 'on')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status];
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,13 +46,15 @@ class Product extends BasicWeChat
|
||||
* @param array $openids 测试人员的openid列表
|
||||
* @param array $usernames 测试人员的微信号列表
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setTestWhiteList(array $openids = [], array $usernames = [])
|
||||
{
|
||||
$data = ['openid' => $openids, 'username' => $usernames];
|
||||
$url = "https://api.weixin.qq.com/scan/testwhitelist/set?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,15 +64,16 @@ class Product extends BasicWeChat
|
||||
* @param integer $qrcode_size 二维码的尺寸(整型),数值代表边长像素数,不填写默认值为100
|
||||
* @param array $extinfo 由商户自定义传入,建议仅使用大小写字母、数字及-_().*这6个常用字符
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getQrcode($keystandard, $keystr, $qrcode_size, $extinfo = [])
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'qrcode_size' => $qrcode_size];
|
||||
empty($extinfo) || $data['extinfo'] = $extinfo;
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,15 +81,16 @@ class Product extends BasicWeChat
|
||||
* @param string $keystandard 商品编码标准
|
||||
* @param string $keystr 商品编码内容
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getProduct($keystandard, $keystr)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr];
|
||||
empty($extinfo) || $data['extinfo'] = $extinfo;
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,29 +100,32 @@ class Product extends BasicWeChat
|
||||
* @param null|string $status 支持按状态拉取。on为发布状态,off为未发布状态,check为审核中状态,reject为审核未通过状态,all为所有状态
|
||||
* @param string $keystr 支持按部分编码内容拉取。填写该参数后,可将编码内容中包含所传参数的商品信息拉出。类似关键词搜索
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getProductList($offset, $limit = 10, $status = null, $keystr = '')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
|
||||
$data = ['offset' => $offset, 'limit' => $limit];
|
||||
is_null($status) || $data['status'] = $status;
|
||||
empty($keystr) || $data['keystr'] = $keystr;
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新商品信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateProduct(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,26 +133,29 @@ class Product extends BasicWeChat
|
||||
* @param string $keystandard 商品编码标准
|
||||
* @param string $keystr 商品编码内容
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function clearProduct($keystandard, $keystr)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/clear?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查wxticket参数
|
||||
* @param string $ticket
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function scanTicketCheck($ticket)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['ticket' => $ticket]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['ticket' => $ticket]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,13 +164,15 @@ class Product extends BasicWeChat
|
||||
* @param string $keystr 商品编码内容
|
||||
* @param string $extinfo 调用“获取商品二维码接口”时传入的extinfo,为标识参数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function clearScanticket($keystandard, $keystr, $extinfo)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo];
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WeChat\Prpcrypt;
|
||||
|
||||
/**
|
||||
* 仅用作类内部使用
|
||||
* 不用于官方API接口的errCode码
|
||||
* Class ErrorCode
|
||||
*/
|
||||
class ErrorCode
|
||||
{
|
||||
|
||||
public static $OK = 0;
|
||||
public static $ParseXmlError = 40002;
|
||||
public static $IllegalAesKey = 40004;
|
||||
public static $IllegalBuffer = 40008;
|
||||
public static $EncryptAESError = 40006;
|
||||
public static $DecryptAESError = 40007;
|
||||
public static $EncodeBase64Error = 40009;
|
||||
public static $DecodeBase64Error = 40010;
|
||||
public static $GenReturnXmlError = 40011;
|
||||
public static $ValidateAppidError = 40005;
|
||||
public static $ComputeSignatureError = 40003;
|
||||
public static $ValidateSignatureError = 40001;
|
||||
public static $errCode = [
|
||||
'0' => '处理成功',
|
||||
'40001' => '校验签名失败',
|
||||
'40002' => '解析xml失败',
|
||||
'40003' => '计算签名失败',
|
||||
'40004' => '不合法的AESKey',
|
||||
'40005' => '校验AppID失败',
|
||||
'40006' => 'AES加密失败',
|
||||
'40007' => 'AES解密失败',
|
||||
'40008' => '公众平台发送的xml不合法',
|
||||
'40009' => 'Base64编码失败',
|
||||
'40010' => 'Base64解码失败',
|
||||
'40011' => '公众帐号生成回包xml失败',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取错误消息内容
|
||||
* @param string $code 错误代码
|
||||
* @return bool
|
||||
*/
|
||||
public static function getErrText($code)
|
||||
{
|
||||
if (isset(self::$errCode[$code])) {
|
||||
return self::$errCode[$code];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WeChat\Prpcrypt;
|
||||
|
||||
/**
|
||||
* PKCS7算法 - 加解密
|
||||
* Class PKCS7Encoder
|
||||
*/
|
||||
class PKCS7Encoder
|
||||
{
|
||||
|
||||
public static $blockSize = 32;
|
||||
|
||||
/**
|
||||
* 对需要加密的明文进行填充补位
|
||||
* @param string $text 需要进行填充补位操作的明文
|
||||
* @return string 补齐明文字符串
|
||||
*/
|
||||
function encode($text)
|
||||
{
|
||||
$amount_to_pad = PKCS7Encoder::$blockSize - (strlen($text) % PKCS7Encoder::$blockSize);
|
||||
if ($amount_to_pad == 0) {
|
||||
$amount_to_pad = PKCS7Encoder::$blockSize;
|
||||
}
|
||||
list($pad_chr, $tmp) = [chr($amount_to_pad), ''];
|
||||
for ($index = 0; $index < $amount_to_pad; $index++) {
|
||||
$tmp .= $pad_chr;
|
||||
}
|
||||
return $text . $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对解密后的明文进行补位删除
|
||||
* @param string $text 解密后的明文
|
||||
* @return string 删除填充补位后的明文
|
||||
*/
|
||||
function decode($text)
|
||||
{
|
||||
$pad = ord(substr($text, -1));
|
||||
if ($pad < 1 || $pad > PKCS7Encoder::$blockSize) {
|
||||
$pad = 0;
|
||||
}
|
||||
return substr($text, 0, strlen($text) - $pad);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -31,8 +29,8 @@ class Qrcode extends BasicWeChat
|
||||
* @param string|integer $scene 场景
|
||||
* @param int $expire_seconds 有效时间
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create($scene, $expire_seconds = 0)
|
||||
{
|
||||
@ -48,7 +46,8 @@ class Qrcode extends BasicWeChat
|
||||
$data['action_name'] = is_integer($scene) ? 'QR_LIMIT_SCENE' : 'QR_LIMIT_STR_SCENE';
|
||||
}
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,19 +57,21 @@ class Qrcode extends BasicWeChat
|
||||
*/
|
||||
public function url($ticket)
|
||||
{
|
||||
return "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . urlencode($ticket);
|
||||
return "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$ticket}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 长链接转短链接接口
|
||||
* @param string $longUrl 需要转换的长链接
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function shortUrl($longUrl)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['action' => 'long2short', 'long_url' => $longUrl]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['action' => 'long2short', 'long_url' => $longUrl]);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -28,26 +26,28 @@ class Scan extends BasicWeChat
|
||||
/**
|
||||
* 获取商户信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getMerchantInfo()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/merchantinfo/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addProduct(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,14 +56,15 @@ class Scan extends BasicWeChat
|
||||
* @param string $keystr 商品编码内容
|
||||
* @param string $status 设置发布状态。on为提交审核,off为取消发布
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function modProduct($keystandard, $keystr, $status = 'on')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status];
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,13 +72,15 @@ class Scan extends BasicWeChat
|
||||
* @param array $openids 测试人员的openid列表
|
||||
* @param array $usernames 测试人员的微信号列表
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setTestWhiteList($openids = [], $usernames = [])
|
||||
{
|
||||
$data = ['openid' => $openids, 'username' => $usernames];
|
||||
$url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,15 +90,16 @@ class Scan extends BasicWeChat
|
||||
* @param null|string $extinfo
|
||||
* @param integer $qrcode_size
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getQrc($keystandard, $keystr, $extinfo = null, $qrcode_size = 64)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN";
|
||||
$data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'qrcode_size' => $qrcode_size];
|
||||
is_null($extinfo) || $data['extinfo'] = $extinfo;
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,13 +107,14 @@ class Scan extends BasicWeChat
|
||||
* @param string $keystandard 商品编码标准
|
||||
* @param string $keystr 商品编码内容
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getProductInfo($keystandard, $keystr)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,29 +124,31 @@ class Scan extends BasicWeChat
|
||||
* @param string $status 支持按状态拉取。on为发布状态,off为未发布状态,check为审核中状态,reject为审核未通过状态,all为所有状态。
|
||||
* @param string $keystr 支持按部分编码内容拉取。填写该参数后,可将编码内容中包含所传参数的商品信息拉出。类似关键词搜索。
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getProductList($offset = 1, $limit = 10, $status = null, $keystr = null)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/getlist?access_token=ACCESS_TOKEN";
|
||||
$data = ['offset' => $offset, 'limit' => $limit];
|
||||
is_null($status) || $data['status'] = $status;
|
||||
is_null($keystr) || $data['keystr'] = $keystr;
|
||||
return $this->callPostApi($url, $data);
|
||||
$url = "https://api.weixin.qq.com/scan/product/getlist?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateProduct(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,26 +156,28 @@ class Scan extends BasicWeChat
|
||||
* @param string $keystandard 商品编码标准
|
||||
* @param string $keystr 商品编码内容
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function clearProduct($keystandard, $keystr)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/product/clear?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查wxticket参数
|
||||
* @param string $ticket
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function checkTicket($ticket)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['ticket' => $ticket]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['ticket' => $ticket]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,12 +186,14 @@ class Scan extends BasicWeChat
|
||||
* @param string $keystr 商品编码内容
|
||||
* @param string $extinfo 调用“获取商品二维码接口”时传入的extinfo,为标识参数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function clearScanTicket($keystandard, $keystr, $extinfo)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]);
|
||||
}
|
||||
|
||||
}
|
@ -3,21 +3,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
/**
|
||||
@ -46,8 +44,8 @@ class Script extends BasicWeChat
|
||||
* @param string $type TICKET类型(wx_card|jsapi)
|
||||
* @param string $appid 强制指定有效APPID
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getTicket($type = 'jsapi', $appid = null)
|
||||
{
|
||||
@ -62,7 +60,7 @@ class Script extends BasicWeChat
|
||||
throw new InvalidResponseException('Invalid Resoponse Ticket.', '0');
|
||||
}
|
||||
$ticket = $result['ticket'];
|
||||
Tools::setCache($cache_name, $ticket, 7000);
|
||||
Tools::setCache($cache_name, $ticket, 5000);
|
||||
}
|
||||
return $ticket;
|
||||
}
|
||||
@ -72,23 +70,15 @@ class Script extends BasicWeChat
|
||||
* @param string $url 网页的URL
|
||||
* @param string $appid 用于多个appid时使用(可空)
|
||||
* @param string $ticket 强制指定ticket
|
||||
* @param array $jsApiList 需初始化的 jsApiList
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function getJsSign($url, $appid = null, $ticket = null, $jsApiList = null)
|
||||
public function getJsSign($url, $appid = null, $ticket = null)
|
||||
{
|
||||
list($url,) = explode('#', $url);
|
||||
is_null($ticket) && $ticket = $this->getTicket('jsapi');
|
||||
is_null($appid) && $appid = $this->config->get('appid');
|
||||
is_null($jsApiList) && $jsApiList = [
|
||||
'updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
|
||||
'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
|
||||
'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
|
||||
'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
|
||||
'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
|
||||
];
|
||||
$data = ["url" => $url, "timestamp" => '' . time(), "jsapi_ticket" => $ticket, "noncestr" => Tools::createNoncestr(16)];
|
||||
return [
|
||||
'debug' => false,
|
||||
@ -96,7 +86,17 @@ class Script extends BasicWeChat
|
||||
"nonceStr" => $data['noncestr'],
|
||||
"timestamp" => $data['timestamp'],
|
||||
"signature" => $this->getSignature($data, 'sha1'),
|
||||
'jsApiList' => $jsApiList,
|
||||
'jsApiList' => [
|
||||
'onWXDeviceBluetoothStateChange', 'onWXDeviceStateChange',
|
||||
'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
|
||||
'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
|
||||
'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
|
||||
'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'closeWindow', 'scanQRCode', 'chooseWXPay',
|
||||
'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
|
||||
'startScanWXDevice', 'stopScanWXDevice', 'onWXDeviceBindStateChange', 'onScanWXDeviceResult', 'onReceiveDataFromWXDevice',
|
||||
'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
|
||||
'openWXDeviceLib', 'closeWXDeviceLib', 'getWXDeviceInfos', 'sendDataToWXDevice', 'disconnectWXDevice', 'getWXDeviceTicket', 'connectWXDevice',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -104,14 +104,18 @@ class Script extends BasicWeChat
|
||||
* 数据生成签名
|
||||
* @param array $data 签名数组
|
||||
* @param string $method 签名方法
|
||||
* @param array $params 签名参数
|
||||
* @return bool|string 签名值
|
||||
*/
|
||||
protected function getSignature($data, $method = "sha1", $params = [])
|
||||
protected function getSignature($data, $method = "sha1")
|
||||
{
|
||||
if (!function_exists($method)) {
|
||||
return false;
|
||||
}
|
||||
ksort($data);
|
||||
if (!function_exists($method)) return false;
|
||||
foreach ($data as $k => $v) $params[] = "{$k}={$v}";
|
||||
$params = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$params[] = "{$key}={$value}";
|
||||
}
|
||||
return $method(join('&', $params));
|
||||
}
|
||||
}
|
199
WeChat/Shake.php
199
WeChat/Shake.php
@ -3,21 +3,20 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 揺一揺周边
|
||||
@ -30,25 +29,27 @@ class Shake extends BasicWeChat
|
||||
* 申请开通功能
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function register(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/account/register?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审核状态
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function auditStatus()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/account/auditstatus?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,8 +59,8 @@ class Shake extends BasicWeChat
|
||||
* @param null|string $comment 备注,不超过15个汉字或30个英文字母
|
||||
* @param null|string $poi_id 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createApply($quantity, $apply_reason, $comment = null, $poi_id = null)
|
||||
{
|
||||
@ -67,111 +68,120 @@ class Shake extends BasicWeChat
|
||||
is_null($poi_id) || $data['poi_id'] = $poi_id;
|
||||
is_null($comment) || $data['comment'] = $comment;
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/applyid?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备ID申请审核状态
|
||||
* @param integer $applyId 批次ID,申请设备ID时所返回的批次ID
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getApplyStatus($applyId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/applyid?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['apply_id' => $applyId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['apply_id' => $applyId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑设备信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateApply(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置设备与门店的关联关系
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function bindLocation(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/bindlocation?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function search(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/search?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面管理
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createPage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/page/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑页面信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updatePage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/page/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询页面列表
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function searchPage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/page/search?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除页面
|
||||
* @param integer $pageId 指定页面的id
|
||||
* @param integer page_id 指定页面的id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deletePage($pageId)
|
||||
public function deletePage($page_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/page/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['page_id' => $pageId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['page_id' => $page_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,108 +189,116 @@ class Shake extends BasicWeChat
|
||||
* @param string $filename 图片名字
|
||||
* @param string $type Icon:摇一摇页面展示的icon图;License:申请开通摇一摇周边功能时需上传的资质文件;若不传type,则默认type=icon
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function upload($filename, $type = 'icon')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/material/add?access_token=ACCESS_TOKEN&type={$type}";
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置设备与页面的关联关系
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function bindPage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备与页面的关联关系
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryPage(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/relation/search?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以设备为维度的数据统计接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function totalDevice(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/statistics/device?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询设备统计数据接口
|
||||
* @param integer $date 指定查询日期时间戳,单位为秒
|
||||
* @param integer $pageIndex 指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页
|
||||
* @param integer $page_index 指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function totalDeviceList($date, $pageIndex = 1)
|
||||
public function totalDeviceList($date, $page_index = 1)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/statistics/devicelist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['date' => $date, 'page_index' => $pageIndex]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['date' => $date, 'page_index' => $page_index]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以页面为维度的数据统计接口
|
||||
* @param integer $pageId 指定页面的设备ID
|
||||
* @param integer $beginDate 起始日期时间戳,最长时间跨度为30天,单位为秒
|
||||
* @param integer $endDate 结束日期时间戳,最长时间跨度为30天,单位为秒
|
||||
* @param integer $page_id 指定页面的设备ID
|
||||
* @param integer $begin_date 起始日期时间戳,最长时间跨度为30天,单位为秒
|
||||
* @param integer $end_date 结束日期时间戳,最长时间跨度为30天,单位为秒
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function totalPage($pageId, $beginDate, $endDate)
|
||||
public function totalPage($page_id, $begin_date, $end_date)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/statistics/page?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['page_id' => $pageId, 'begin_date' => $beginDate, 'end_date' => $endDate]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑分组信息
|
||||
* @param integer $groupId 分组唯一标识,全局唯一
|
||||
* @param string $groupName 分组名称,不超过100汉字或200个英文字母
|
||||
* @param integer $group_id 分组唯一标识,全局唯一
|
||||
* @param string $group_name 分组名称,不超过100汉字或200个英文字母
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateGroup($groupId, $groupName)
|
||||
public function updateGroup($group_id, $group_name)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['group_id' => $groupId, 'group_name' => $groupName]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['group_id' => $group_id, 'group_name' => $group_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
* @param integer $groupId 分组唯一标识,全局唯一
|
||||
* @param integer $group_id 分组唯一标识,全局唯一
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteGroup($groupId)
|
||||
public function deleteGroup($group_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['group_id' => $groupId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['group_id' => $group_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,13 +306,14 @@ class Shake extends BasicWeChat
|
||||
* @param integer $begin 分组列表的起始索引值
|
||||
* @param integer $count 待查询的分组数量,不能超过1000个
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGroupList($begin = 0, $count = 10)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/getlist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['begin' => $begin, 'count' => $count]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['begin' => $begin, 'count' => $count]);
|
||||
}
|
||||
|
||||
|
||||
@ -304,38 +323,42 @@ class Shake extends BasicWeChat
|
||||
* @param integer $begin 分组里设备的起始索引值
|
||||
* @param integer $count 待查询的分组里设备的数量,不能超过1000个
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGroupDetail($group_id, $begin = 0, $count = 100)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/getdetail?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['group_id' => $group_id, 'begin' => $begin, 'count' => $count]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['group_id' => $group_id, 'begin' => $begin, 'count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加设备到分组
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addDeviceGroup(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/adddevice?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从分组中移除设备
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteDeviceGroup(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -33,7 +31,8 @@ class Tags extends BasicWeChat
|
||||
public function getTags()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +45,8 @@ class Tags extends BasicWeChat
|
||||
public function createTags($name)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['tag' => ['name' => $name]]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['tag' => ['name' => $name]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +60,8 @@ class Tags extends BasicWeChat
|
||||
public function updateTags($id, $name)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['tag' => ['name' => $name, 'id' => $id]]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['tag' => ['name' => $name, 'id' => $id]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,7 +74,8 @@ class Tags extends BasicWeChat
|
||||
public function deleteTags($tagId)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['tag' => ['id' => $tagId]]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['tag' => ['id' => $tagId]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,7 +89,8 @@ class Tags extends BasicWeChat
|
||||
public function batchTagging(array $openids, $tagId)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['openid_list' => $openids, 'tagid' => $tagId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid_list' => $openids, 'tagid' => $tagId]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +104,8 @@ class Tags extends BasicWeChat
|
||||
public function batchUntagging(array $openids, $tagId)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['openid_list' => $openids, 'tagid' => $tagId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid_list' => $openids, 'tagid' => $tagId]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,6 +118,7 @@ class Tags extends BasicWeChat
|
||||
public function getUserTagId($openid)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['openid' => $openid]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid' => $openid]);
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -27,16 +25,17 @@ class Template extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 设置所属行业
|
||||
* @param string $industryId1 公众号模板消息所属行业编号
|
||||
* @param string $industryId2 公众号模板消息所属行业编号
|
||||
* @param string $industry_id1 公众号模板消息所属行业编号
|
||||
* @param string $industry_id2 公众号模板消息所属行业编号
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setIndustry($industryId1, $industryId2)
|
||||
public function setIndustry($industry_id1, $industry_id2)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['industry_id1' => $industryId1, 'industry_id2' => $industryId2]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['industry_id1' => $industry_id1, 'industry_id2' => $industry_id2]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,21 +47,22 @@ class Template extends BasicWeChat
|
||||
public function getIndustry()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得模板ID
|
||||
* @param string $templateIdShort 板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
||||
* @param array $keywordNameList 选用的类目模板的关键词
|
||||
* @param string $tpl_id 板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addTemplate($templateIdShort, $keywordNameList = [])
|
||||
public function addTemplate($tpl_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['template_id_short' => $templateIdShort, 'keyword_name_list' => $keywordNameList]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['template_id_short' => $tpl_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,20 +74,22 @@ class Template extends BasicWeChat
|
||||
public function getAllPrivateTemplate()
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN";
|
||||
return $this->callGetApi($url);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板ID
|
||||
* @param string $tplId 公众帐号下模板消息ID
|
||||
* @param string $tpl_id 公众帐号下模板消息ID
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delPrivateTemplate($tplId)
|
||||
public function delPrivateTemplate($tpl_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['template_id' => $tplId]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['template_id' => $tpl_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,6 +102,9 @@ class Template extends BasicWeChat
|
||||
public function send(array $data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
@ -37,7 +35,8 @@ class User extends BasicWeChat
|
||||
public function updateMark($openid, $remark)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['openid' => $openid, 'remark' => $remark]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid' => $openid, 'remark' => $remark]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,8 +49,9 @@ class User extends BasicWeChat
|
||||
*/
|
||||
public function getUserInfo($openid, $lang = 'zh_CN')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid={$openid}&lang={$lang}";
|
||||
return $this->callGetApi($url);
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid={$openid}&lang=zh_CN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +69,8 @@ class User extends BasicWeChat
|
||||
foreach ($openids as $openid) {
|
||||
$data['user_list'][] = ['openid' => $openid, 'lang' => $lang];
|
||||
}
|
||||
return $this->callPostApi($url, $data);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,34 +83,22 @@ class User extends BasicWeChat
|
||||
public function getUserList($next_openid = '')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid={$next_openid}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签下粉丝列表
|
||||
* @param integer $tagid 标签ID
|
||||
* @param string $nextOpenid 第一个拉取的OPENID
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getUserListByTag($tagid, $nextOpenid = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['tagid' => $tagid, 'next_openid' => $nextOpenid]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpGetForJson($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号的黑名单列表
|
||||
* @param string $beginOpenid
|
||||
* @param string $begin_openid
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getBlackList($beginOpenid = '')
|
||||
public function getBlackList($begin_openid = '')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/getblacklist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['begin_openid' => $beginOpenid]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['begin_openid' => $begin_openid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +111,8 @@ class User extends BasicWeChat
|
||||
public function batchBlackList(array $openids)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchblacklist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['openid_list' => $openids]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid_list' => $openids]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,6 +125,8 @@ class User extends BasicWeChat
|
||||
public function batchUnblackList(array $openids)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchunblacklist?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['openid_list' => $openids]);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['openid_list' => $openids]);
|
||||
}
|
||||
|
||||
}
|
@ -3,19 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat;
|
||||
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -20,7 +18,6 @@ use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidDecryptException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WXBizDataCrypt;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,12 +33,12 @@ class Crypt extends BasicWeChat
|
||||
* @param string $iv
|
||||
* @param string $sessionKey
|
||||
* @param string $encryptedData
|
||||
* @return bool|array
|
||||
* @return bool
|
||||
*/
|
||||
public function decode($iv, $sessionKey, $encryptedData)
|
||||
{
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'crypt' . DIRECTORY_SEPARATOR . 'wxBizDataCrypt.php';
|
||||
$pc = new WXBizDataCrypt($this->config->get('appid'), $sessionKey);
|
||||
$pc = new \WXBizDataCrypt($this->config->get('appid'), $sessionKey);
|
||||
$errCode = $pc->decryptData($encryptedData, $iv, $data);
|
||||
if ($errCode == 0) {
|
||||
return json_decode($data, true);
|
||||
@ -53,7 +50,6 @@ class Crypt extends BasicWeChat
|
||||
* 登录凭证校验
|
||||
* @param string $code 登录时获取的 code
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function session($code)
|
||||
{
|
||||
@ -69,9 +65,8 @@ class Crypt extends BasicWeChat
|
||||
* @param string $iv 加密算法的初始向量
|
||||
* @param string $encryptedData 加密数据( encryptedData )
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidDecryptException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function userInfo($code, $iv, $encryptedData)
|
||||
{
|
||||
@ -81,42 +76,8 @@ class Crypt extends BasicWeChat
|
||||
}
|
||||
$userinfo = $this->decode($iv, $result['session_key'], $encryptedData);
|
||||
if (empty($userinfo)) {
|
||||
throw new InvalidDecryptException('用户信息解析失败', 403);
|
||||
throw new InvalidDecryptException('用户信息解析失败', 403);
|
||||
}
|
||||
return array_merge($result, $userinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过授权码换取手机号
|
||||
* @param string $code
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPhoneNumber($code)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->httpPostForJson($url, ['code' => $code], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户支付完成后,获取该用户的 UnionId
|
||||
* @param string $openid 支付用户唯一标识
|
||||
* @param null|string $transaction_id 微信支付订单号
|
||||
* @param null|string $mch_id 微信支付分配的商户号,和商户订单号配合使用
|
||||
* @param null|string $out_trade_no 微信支付商户订单号,和商户号配合使用
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPaidUnionId($openid, $transaction_id = null, $mch_id = null, $out_trade_no = null)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/getpaidunionid?access_token=ACCESS_TOKEN&openid={$openid}";
|
||||
if (is_null($mch_id)) $url .= "&mch_id={$mch_id}";
|
||||
if (is_null($out_trade_no)) $url .= "&out_trade_no={$out_trade_no}";
|
||||
if (is_null($transaction_id)) $url .= "&transaction_id={$transaction_id}";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
}
|
@ -1,209 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序客服服务
|
||||
* Class Custom
|
||||
* @package WeMini
|
||||
*/
|
||||
class Custom extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建商户
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessRegister($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/business/register?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商户信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessUpdate($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/business/update?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉取单个商户信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessGet($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/business/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拉取多个商户信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessList($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/business/list?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送客服消息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessSend($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/message/custom/business/send?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客服输入状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessTyping($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi‐bin/message/custom/business/typing?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取客服基本信息
|
||||
* @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getKfList($business_id = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN';
|
||||
if (!empty($business_id)) {
|
||||
$url .= '&business_id=' . $business_id;
|
||||
}
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取在线客服列表
|
||||
* @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getOnlineKfList($business_id = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN';
|
||||
if (!empty($business_id)) {
|
||||
$url .= '&business_id=' . $business_id;
|
||||
}
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 客服输入状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addKfAccount($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除客服账号
|
||||
* @param string $kf_openid 客服openid
|
||||
* @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delKfAccount($kf_openid, $business_id = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid;
|
||||
if (!empty($business_id)) {
|
||||
$url .= '&business_id=' . $business_id;
|
||||
}
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置客服管理员
|
||||
* @param string $kf_openid 客服openid
|
||||
* @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setKfAdmin($kf_openid, $business_id = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/setadmin?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid;
|
||||
if (!empty($business_id)) {
|
||||
$url .= '&business_id=' . $business_id;
|
||||
}
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消客服管理员
|
||||
* @param string $kf_openid 客服openid
|
||||
* @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function cancelKfAdmin($kf_openid, $business_id = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/canceladmin?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid;
|
||||
if (!empty($business_id)) {
|
||||
$url .= '&business_id=' . $business_id;
|
||||
}
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
}
|
@ -1,172 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序即时配送
|
||||
* Class Delivery
|
||||
* @package WeMini
|
||||
*/
|
||||
class Delivery extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 异常件退回商家商家确认收货接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function abnormalConfirm($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/confirm_return?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下配送单接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/add?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可以对待接单状态的订单增加小费
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addTip($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/addtips?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消配送单接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function cancelOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/cancel?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已支持的配送公司列表接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getAllImmeDelivery($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/delivery/getall?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取已绑定账号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getBindAccount($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/shop/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取配送单信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟配送公司更新配送单状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function mockUpdateOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/test_update_order?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预下配送单接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function preAddOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预取消配送单接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function preCancelOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/precancel?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新下单
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function reOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/readd?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
}
|
527
WeMini/Guide.php
527
WeMini/Guide.php
@ -1,527 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序导购助手
|
||||
* Class Guide
|
||||
* @package WeMini
|
||||
*/
|
||||
class Guide extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 服务号添加导购
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGuideAcct($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/addguideacct?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务号删除导购
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideAcct($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguideacct?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务号获取导购信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideAcct($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacct?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务号的敏感词信息与自动回复信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideAcctConfig()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacctconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务号拉取导购列表
|
||||
* @param integer $page
|
||||
* @param integer $num
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideAcctList($page = 0, $num = 10)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacctconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['page' => $page, 'num' => $num], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导购聊天记录
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerChatRecord($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacct?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导购快捷回复信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideConfig($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成导购二维码
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function guideCreateQrCode($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/guidecreateqrcode?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function pushShowWxaPathMenu($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/pushshowwxapathmenu?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为服务号设置敏感词与自动回复
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setGuideAcctConfig($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideacctconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置导购快捷回复信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setGuideConfig($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新导购昵称或者头像
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateGuideAcct($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideconfig?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加展示标签信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGuideBuyerDisplayTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerdisplaytag?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为粉丝添加可查询标签
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGuideBuyerTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyertag?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加标签可选值
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGuideTagOption($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidetagoption?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除粉丝标签
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideBuyerTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidebuyertag?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询展示标签信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerDisplayTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerdisplaytag?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询粉丝标签
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyertag?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询标签可选值信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideTagOption()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidetagoption?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建可查询标签类型,支持新建4类可查询标签
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function newGuideTagOption($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/newguidetagoption?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签值筛选粉丝
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryGuideBuyerByTag($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/queryguidebuyerbytag?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为服务号导购添加粉丝
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGuideBuyerRelation($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerrelation?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导购的粉丝
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideBuyerRelation($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidebuyerrelation?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某一个粉丝与导购的绑定关系
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerRelation($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过粉丝信息查询该粉丝与导购的绑定关系
|
||||
* @param string $openid
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerRelationByBuyer($openid)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['openid' => $openid], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取导购的粉丝列表
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideBuyerRelationList($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationlist?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将粉丝从一个导购迁移到另外一个导购下
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function rebindGuideAcctForBuyer($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/rebindguideacctforbuyer?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新粉丝昵称
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateGuideBuyerRelation($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/updateguidebuyerrelation?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序卡片素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideCardMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidecardmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图片素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideImageMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguideimagematerial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文字素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delGuideWordMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidewordmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序卡片素材信息
|
||||
* @param integer $type
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideCardMaterial($type = 0)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidecardmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['type' => $type], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片素材信息
|
||||
* @param integer $type 操作类型
|
||||
* @param integer $start 分页查询,起始位置
|
||||
* @param integer $num 分页查询,查询个数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideImageMaterial($type = 0, $start = 0, $num = 10)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideimagematerial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['type' => $type, 'start' => $start, 'num' => $num], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文字素材信息
|
||||
* @param integer $type 操作类型
|
||||
* @param integer $start 分页查询,起始位置
|
||||
* @param integer $num 分页查询,查询个数
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGuideWordMaterial($type = 0, $start = 0, $num = 10)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidewordmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['type' => $type, 'start' => $start, 'num' => $num], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加小程序卡片素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setGuideCardMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguidecardmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图片素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setGuideImageMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideimagematerial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为服务号添加文字素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setGuideWordMaterial($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/setguidewordmaterial?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序图像处理
|
||||
* Class Image
|
||||
* @package WeMini
|
||||
*/
|
||||
class Image extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的图片智能裁剪能力
|
||||
* @param string $img_url 要检测的图片 url,传这个则不用传 img 参数。
|
||||
* @param string $img form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用穿 img_url
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function aiCrop($img_url, $img)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cv/img/aicrop?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的条码/二维码识别的API
|
||||
* @param string $img_url 要检测的图片 url,传这个则不用传 img 参数。
|
||||
* @param string $img form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用穿 img_url
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function scanQRCode($img_url, $img)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的图片高清化能力
|
||||
* @param string $img_url 要检测的图片 url,传这个则不用传 img 参数
|
||||
* @param string $img form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用穿 img_url
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function superresolution($img_url, $img)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true);
|
||||
}
|
||||
}
|
@ -1,209 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序运费险
|
||||
* Class Insurance
|
||||
* @package WeMini
|
||||
*/
|
||||
class Insurance extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 开通无忧退货接口
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/open?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询开通状态接口
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryOpen()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/query_open?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 投保接口(发货时投保)
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/createorder?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 理赔接口 (收到用户退货后再触发)
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function claim($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/claim?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请充值订单号接口 (支持自定义金额)
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createChargeId($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/createchargeid?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请支付接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function applyPay($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/applypay?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取充值订单信息接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPayOrderList($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/getpayorderlist?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 退款接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function refund($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/refund?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取摘要接口 (查询当前保费、投保单量、理赔单量、账号余额等信息)
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getSummary($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/getsummary?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取保单信息接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getOrderList($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/getorderlist?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置告警余额接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateNotifyFunds($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/insurance_freight/update_notify_funds?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建退货 ID
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function returnAdd($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/no_worry_return/add?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询退货 ID 状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function returnGet($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/no_worry_return/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查解绑退货 ID
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function returnUbind($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/no_worry_return/unbind?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
518
WeMini/Live.php
518
WeMini/Live.php
@ -1,518 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序直播接口
|
||||
* Class Live
|
||||
* @package WeMini
|
||||
*/
|
||||
class Live extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 创建直播间
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播房间列表
|
||||
* @param integer $start 起始拉取房间
|
||||
* @param integer $limit 每次拉取的个数上限
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getLiveList($start = 0, $limit = 10)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['start' => $start, 'limit' => $limit], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取回放源视频
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getLiveInfo($data = [])
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间导入商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addLiveGoods($data = [])
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品添加并提审
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品撤回审核
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function resetAuditGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新提交审核
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function auditGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/audit?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function stateGoods($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @param integer $offset 分页条数起点
|
||||
* @param integer $status 商品状态,0:未审核。1:审核中,2:审核通过,3:审核驳回
|
||||
* @param integer $limit 分页大小,默认30,不超过100
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getGoods($offset, $status, $limit = 30)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=ACCESS_TOKEN&offset={$offset}&limit={$limit}&status={$status}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除直播间
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delLive($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑直播间
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function editLive($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播间推流地址
|
||||
* @param string $roomId
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPushUrl($roomId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getpushurl?access_token=ACCESS_TOKEN&roomId={$roomId}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取直播间分享二维码
|
||||
* @param string $roomId
|
||||
* @param string $params
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getShareCode($roomId, $params = '')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsharedcode?access_token=ACCESS_TOKEN&roomId={$roomId}¶ms={$params}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加管理直播间小助手
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addAssistant($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addassistant?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改管理直播间小助手
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function modifyAssistant($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除管理直播间小助手
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function removeAssistant($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/removeassistant?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询管理直播间小助手
|
||||
* @param string $roomId
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getAssistantList($roomId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getassistantlist?access_token=ACCESS_TOKEN&roomId={$roomId}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加主播副号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addSubAnchor($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改主播副号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function modifySubAnchor($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/modifysubanchor?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修删除主播副号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delSubAnchor($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询除主播副号
|
||||
* @param string $roomId
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getSubAnchor($roomId)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor?access_token=ACCESS_TOKEN&roomId={$roomId}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭直播间官方收录
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateFeedPublic($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭回放功能
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateReplay($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭客服功能
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateKf($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启/关闭直播间全局禁言
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateComment($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下架商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function goodsOnsale($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除直播间商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function goodsDeleteInRoom($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送商品
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function goodsPush($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品排序
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function goodsSort($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/sort?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载商品讲解视频
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getVideo($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getVideo?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取长期订阅用户
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getFollowers($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/business/get_wxa_followers?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 长期订阅群发接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function pushMessage($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/business/push_message?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置成员角色
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addRole($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/role/addrole?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解除成员角色
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delRole($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/role/deleterole?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询成员角色
|
||||
* @param int $role
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @param string $keyword
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getRole($role = -1, $offset = 0, $limit = 30, $keyword = '')
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxaapi/broadcast/role/getrolelist?access_token=ACCESS_TOKEN&offset={$offset}&limit={$limit}&keyword={$keyword}&role={$role}";
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序物流助手
|
||||
* Class Logistics
|
||||
* @package WeMini
|
||||
*/
|
||||
class Logistics extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 生成运单
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/add?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消运单
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function cancelOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/cancel?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支持的快递公司列表
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getAllDelivery()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/delivery/getall?access_token=ACCESS_TOKEN';
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单数据
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询运单轨迹
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPath($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打印员。若需要使用微信打单 PC 软件,才需要调用
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPrinter()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/getall?access_token=ACCESS_TOKEN';
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getQuota($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/quota/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟快递公司更新订单状态, 该接口只能用户测试
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function testUpdateOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/test_update_order?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置面单打印员,若需要使用微信打单 PC 软件,才需要调用
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updatePrinter($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/update?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面单联系人信息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getContact($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/contact/get?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览面单模板。用于调试面单模板使用
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function previewTemplate($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/template/preview?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商户审核结果
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updateBusiness($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/service/business/update?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新运单轨迹
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function updatePath($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/path/update?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绑定/解绑物流账号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function bindAccount($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/account/bind?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有绑定的物流账号
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getAllAccount($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/account/getall?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取运单数据
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function batchGetOrder($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/batchget?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 微信小程序服务市场
|
||||
* Class Ocr
|
||||
* @package WeMini
|
||||
*/
|
||||
class Market extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 调用服务平台上架的API
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function invoke($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/servicemarket?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务市场返回的数据
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function retrieve($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/servicemarketretrieve?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
|
||||
/**
|
||||
* 小程序素材操作
|
||||
* Class Media
|
||||
* @package WeMini
|
||||
*/
|
||||
class Media extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取客服消息内的临时素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get($media_id)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=' . $media_id;
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增图片素材
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function upload($filename)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=image';
|
||||
return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序动态消息
|
||||
* Class Message
|
||||
* @package WeMini
|
||||
*/
|
||||
class Message extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 动态消息,创建被分享动态消息的 activity_id
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createActivityId($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态消息,修改被分享的动态消息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setUpdatableMsg($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发小程序和公众号统一的服务消息
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function uniformSend($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 公众号小程序订阅消息支持
|
||||
* Class Mini
|
||||
* @package WeChat
|
||||
*/
|
||||
class Newtmpl extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 获取小程序账号的类目
|
||||
* @param array $data 类目信息列表
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addCategory($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/addcategory?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序账号的类目
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN';
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序账号的类目
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function deleteCategory()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory?access_token=TOKEN';
|
||||
return $this->callPostApi($url, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帐号所属类目下的公共模板标题
|
||||
* @param string $ids 类目 id,多个用逗号隔开
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPubTemplateTitleList($ids)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN';
|
||||
$url .= '&' . http_build_query(['ids' => $ids, 'start' => '0', 'limit' => '30']);
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板标题下的关键词列表
|
||||
* @param string $tid 模板标题 id,可通过接口获取
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getPubTemplateKeyWordsById($tid)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN';
|
||||
$url .= '&' . http_build_query(['tid' => $tid]);
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组合模板并添加至帐号下的个人模板库
|
||||
* @param string $tid 模板标题 id,可通过接口获取,也可登录小程序后台查看获取
|
||||
* @param array $kidList 开发者自行组合好的模板关键词列表,关键词顺序可以自由搭配(例如 [3,5,4] 或 [4,5,3]),最多支持5个,最少2个关键词组合
|
||||
* @param string $sceneDesc 服务场景描述,15个字以内
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function addTemplate($tid, array $kidList, $sceneDesc = '')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['tid' => $tid, 'kidList' => $kidList, 'sceneDesc' => $sceneDesc], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前帐号下的个人模板列表
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getTemplateList()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=ACCESS_TOKEN';
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帐号下的个人模板
|
||||
* @param string $priTmplId 要删除的模板id
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function delTemplate($priTmplId)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['priTmplId' => $priTmplId], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送订阅消息
|
||||
* @param array $data 发送的消息对象数组
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function send(array $data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
105
WeMini/Ocr.php
105
WeMini/Ocr.php
@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序ORC服务
|
||||
* Class Ocr
|
||||
* @package WeMini
|
||||
*/
|
||||
class Ocr extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 本接口提供基于小程序的银行卡 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function bankcard($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/bankcard?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的营业执照 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function businessLicense($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的驾驶证 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function driverLicense($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/drivinglicense?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的身份证 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function idcard($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/idcard?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的通用印刷体 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function printedText($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本接口提供基于小程序的行驶证 OCR 识别
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function vehicleLicense($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cv/ocr/driving?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, false);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序运维中心
|
||||
* Class Operation
|
||||
* @package WeMini
|
||||
*/
|
||||
class Operation extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 实时日志查询
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function realtimelogSearch($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxaapi/userlog/userlog_search?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -35,6 +33,7 @@ class Plugs extends BasicWeChat
|
||||
public function apply($plugin_appid)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['action' => 'apply', 'plugin_appid' => $plugin_appid], true);
|
||||
}
|
||||
|
||||
@ -47,6 +46,7 @@ class Plugs extends BasicWeChat
|
||||
public function getList()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['action' => 'list'], true);
|
||||
}
|
||||
|
||||
@ -60,22 +60,10 @@ class Plugs extends BasicWeChat
|
||||
public function unbind($plugin_appid)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['action' => 'unbind', 'plugin_appid' => $plugin_appid], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前所有插件使用方
|
||||
* 修改插件使用申请的状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function devplugin($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/devplugin?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4.获取当前所有插件使用方(供插件开发者调用)
|
||||
@ -88,6 +76,7 @@ class Plugs extends BasicWeChat
|
||||
public function devApplyList($page = 1, $num = 10)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$data = ['action' => 'dev_apply_list', 'page' => $page, 'num' => $num];
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
@ -102,6 +91,8 @@ class Plugs extends BasicWeChat
|
||||
public function devAgree($action = 'dev_agree')
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/plugin?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['action' => $action], true);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -38,6 +36,7 @@ class Poi extends BasicWeChat
|
||||
public function addBearByPoi($related_name, $related_credential, $related_address, $related_proof_material)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/addnearbypoi?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$data = [
|
||||
'related_name' => $related_name, 'related_credential' => $related_credential,
|
||||
'related_address' => $related_address, 'related_proof_material' => $related_proof_material,
|
||||
@ -56,6 +55,7 @@ class Poi extends BasicWeChat
|
||||
public function getNearByPoiList($page = 1, $page_rows = 1000)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/getnearbypoilist?page={$page}&page_rows={$page_rows}&access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callGetApi($url);
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ class Poi extends BasicWeChat
|
||||
public function delNearByPoiList($poi_id)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/delnearbypoi?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['poi_id' => $poi_id], true);
|
||||
}
|
||||
|
||||
@ -83,6 +84,8 @@ class Poi extends BasicWeChat
|
||||
public function setNearByPoiShowStatus($poi_id, $status)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/setnearbypoishowstatus?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['poi_id' => $poi_id, 'status' => $status], true);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -20,40 +18,35 @@ use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
|
||||
/**
|
||||
* 微信小程序二维码
|
||||
* 微信小程序二维码管理
|
||||
* Class Qrcode
|
||||
* @package WeMini
|
||||
*/
|
||||
class Qrcode extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 默认线条颜色
|
||||
* @var string[]
|
||||
*/
|
||||
private $lineColor = ["r" => "0", "g" => "0", "b" => "0"];
|
||||
|
||||
/**
|
||||
* 获取小程序码(永久有效)
|
||||
* 接口A: 适用于需要的码数量较少的业务场景
|
||||
* @param string $path 不能为空,最大长度 128 字节
|
||||
* @param integer $width 二维码的宽度
|
||||
* @param bool $autoColor 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param null|array $lineColor auto_color 为 false 时生效
|
||||
* @param boolean $isHyaline 透明底色
|
||||
* @param string|null $outType 输出类型
|
||||
* @param array $extra 其他参数
|
||||
* @return string|array
|
||||
* @param bool $auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param array $line_color auto_color 为 false 时生效
|
||||
* @param null|string $outType 输出类型
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createMiniPath($path, $width = 430, $autoColor = false, $lineColor = null, $isHyaline = true, $outType = null, array $extra = [])
|
||||
public function createMiniPath($path, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"], $outType = null)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/getwxacode?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$lineColor = empty($lineColor) ? $this->lineColor : $lineColor;
|
||||
$data = ['path' => $path, 'width' => $width, 'auto_color' => $autoColor, 'line_color' => $lineColor, 'is_hyaline' => $isHyaline];
|
||||
return $this->parseResult(Tools::post($url, Tools::arr2json(array_merge($data, $extra))), $outType);
|
||||
$data = ['path' => $path, 'width' => $width, 'auto_color' => $auto_color, 'line_color' => $line_color];
|
||||
$result = Tools::post($url, Tools::arr2json($data));
|
||||
if (json_decode($result)) {
|
||||
return Tools::json2arr($result);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,23 +55,23 @@ class Qrcode extends BasicWeChat
|
||||
* @param string $scene 最大32个可见字符,只支持数字
|
||||
* @param string $page 必须是已经发布的小程序存在的页面
|
||||
* @param integer $width 二维码的宽度
|
||||
* @param bool $autoColor 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param null|array $lineColor auto_color 为 false 时生效
|
||||
* @param bool $isHyaline 是否需要透明底色
|
||||
* @param bool $auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param array $line_color auto_color 为 false 时生效
|
||||
* @param null|string $outType 输出类型
|
||||
* @param array $extra 其他参数
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createMiniScene($scene, $page = '', $width = 430, $autoColor = false, $lineColor = null, $isHyaline = true, $outType = null, array $extra = [])
|
||||
public function createMiniScene($scene, $page, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"], $outType = null)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN';
|
||||
$data = ['scene' => $scene, 'width' => $width, 'auto_color' => $auto_color, 'page' => $page, 'line_color' => $line_color];
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$lineColor = empty($lineColor) ? $this->lineColor : $lineColor;
|
||||
$data = ['scene' => $scene, 'width' => $width, 'page' => $page, 'auto_color' => $autoColor, 'line_color' => $lineColor, 'is_hyaline' => $isHyaline, 'check_path' => false];
|
||||
if (empty($page)) unset($data['page']);
|
||||
return $this->parseResult(Tools::post($url, Tools::arr2json(array_merge($data, $extra))), $outType);
|
||||
$result = Tools::post($url, Tools::arr2json($data));
|
||||
if (json_decode($result)) {
|
||||
return Tools::json2arr($result);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +79,7 @@ class Qrcode extends BasicWeChat
|
||||
* 接口C:适用于需要的码数量较少的业务场景
|
||||
* @param string $path 不能为空,最大长度 128 字节
|
||||
* @param integer $width 二维码的宽度
|
||||
* @param string|null $outType 输出类型
|
||||
* @param null|string $outType 输出类型
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
@ -95,26 +88,11 @@ class Qrcode extends BasicWeChat
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->parseResult(Tools::post($url, Tools::arr2json(['path' => $path, 'width' => $width])), $outType);
|
||||
$result = Tools::post($url, Tools::arr2json(['path' => $path, 'width' => $width]));
|
||||
if (json_decode($result)) {
|
||||
return Tools::json2arr($result);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解释接口数据
|
||||
* @param bool|string $result
|
||||
* @param null|string $outType
|
||||
* @return array|mixed
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
private function parseResult($result, $outType)
|
||||
{
|
||||
if (is_array($json = json_decode($result, true))) {
|
||||
if (!$this->isTry && isset($json['errcode']) && in_array($json['errcode'], ['40014', '40001', '41001', '42001'])) {
|
||||
[$this->delAccessToken(), $this->isTry = true];
|
||||
return call_user_func_array([$this, $this->currentMethod['method']], $this->currentMethod['arguments']);
|
||||
}
|
||||
return Tools::json2arr($result);
|
||||
} else {
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序 URL-Scheme
|
||||
* Class Scheme
|
||||
* @package WeMini
|
||||
*/
|
||||
class Scheme extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建 URL-Scheme
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/generatescheme?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 URL-Scheme
|
||||
* @param string $scheme
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($scheme)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/queryscheme?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['scheme' => $scheme], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 URL-Link
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function urlLink($data)
|
||||
{
|
||||
$url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=ACCESS_TOKEN";
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 URL-Link
|
||||
* @param string $urllink
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function urlQuery($urllink)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/query_urllink?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['url_link' => $urllink], true);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序搜索
|
||||
* Class Search
|
||||
* @package WeMini
|
||||
*/
|
||||
class Search extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 提交小程序页面url及参数信息
|
||||
* @param array $pages
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function submitPages($pages)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacct?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['pages' => $pages], true);
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序内容安全
|
||||
* Class Security
|
||||
* @package WeMini
|
||||
*/
|
||||
class Security extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 校验一张图片是否含有违法违规内容
|
||||
* @param string $media 要检测的图片文件,格式支持PNG、JPEG、JPG、GIF,图片尺寸不超过 750px x 1334px
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function imgSecCheck($media)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/img_sec_check?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['media' => $media], false, ['headers' => ['Content-Type: application/octet-stream']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步校验图片/音频是否含有违法违规内容
|
||||
* @param string $media_url
|
||||
* @param string $media_type
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function mediaCheckAsync($media_url, $media_type)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/media_check_async?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['media_url' => $media_url, 'media_type' => $media_type], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查一段文本是否含有违法违规内容
|
||||
* @param string $content
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function msgSecCheck($content)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['content' => $content], true);
|
||||
}
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序发货信息管理服务
|
||||
* @class Shipping
|
||||
* @package WeMini
|
||||
*/
|
||||
class Shipping extends BasicWeChat
|
||||
{
|
||||
|
||||
/**
|
||||
* 发货信息录入接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function upload($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货信息合单录入接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function combined($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/upload_combined_shipping_info?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单发货状态
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单列表
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function qlist($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/get_order_list?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收货提醒接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function confirm($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息跳转路径设置接口
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function setJump($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/set_msg_jump_path?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小程序是否已开通发货信息管理服务
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function isTrade($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/is_trade_managed?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小程序是否已完成交易结算管理确认
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function isCompleted($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/sec/order/is_trade_management_confirmation_completed?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
|
||||
/**
|
||||
* 小程序生物认证
|
||||
* Class Soter
|
||||
* @package WeMini
|
||||
*/
|
||||
class Soter extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* SOTER 生物认证秘钥签名验证
|
||||
* @param array $data
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function verifySignature($data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/soter/verify_signature?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -35,6 +33,7 @@ class Template extends BasicWeChat
|
||||
public function getTemplateLibraryList()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['offset' => '0', 'count' => '20'], true);
|
||||
}
|
||||
|
||||
@ -48,6 +47,7 @@ class Template extends BasicWeChat
|
||||
public function getTemplateLibrary($template_id)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['id' => $template_id], true);
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ class Template extends BasicWeChat
|
||||
public function addTemplate($template_id, array $keyword_id_list)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/add?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['id' => $template_id, 'keyword_id_list' => $keyword_id_list], true);
|
||||
}
|
||||
|
||||
@ -74,6 +75,7 @@ class Template extends BasicWeChat
|
||||
public function getTemplateList()
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['offset' => '0', 'count' => '20'], true);
|
||||
}
|
||||
|
||||
@ -87,6 +89,7 @@ class Template extends BasicWeChat
|
||||
public function delTemplate($template_id)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/template/del?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['template_id' => $template_id], true);
|
||||
}
|
||||
|
||||
@ -100,6 +103,8 @@ class Template extends BasicWeChat
|
||||
public function send(array $data)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, $data, true);
|
||||
}
|
||||
|
||||
}
|
@ -3,15 +3,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeMini;
|
||||
@ -27,30 +25,32 @@ class Total extends BasicWeChat
|
||||
{
|
||||
/**
|
||||
* 数据分析接口
|
||||
* @param string $beginDate 开始日期
|
||||
* @param string $endDate 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
|
||||
* @param string $begin_date 开始日期
|
||||
* @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getWeanalysisAppidDailySummarytrend($beginDate, $endDate)
|
||||
public function getWeanalysisAppidDailySummarytrend($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['begin_date' => $beginDate, 'end_date' => $endDate], true);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 访问分析
|
||||
* @param string $beginDate 开始日期
|
||||
* @param string $endDate 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
|
||||
* @param string $begin_date 开始日期
|
||||
* @param string $end_date 结束日期,限定查询1天数据,end_date允许设置的最大值为昨日
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getWeanalysisAppidDailyVisittrend($beginDate, $endDate)
|
||||
public function getWeanalysisAppidDailyVisittrend($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=ACCESS_TOKEN';
|
||||
return $this->callPostApi($url, ['begin_date' => $beginDate, 'end_date' => $endDate], true);
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,6 +64,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidWeeklyVisittrend($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -78,6 +79,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidMonthlyVisittrend($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -92,6 +94,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidVisitdistribution($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -106,6 +109,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidDailyRetaininfo($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -120,6 +124,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidWeeklyRetaininfo($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -134,6 +139,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidMonthlyRetaininfo($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -148,6 +154,7 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidVisitPage($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
@ -162,6 +169,8 @@ class Total extends BasicWeChat
|
||||
public function getWeanalysisAppidUserportrait($begin_date, $end_date)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
return $this->callPostApi($url, ['begin_date' => $begin_date, 'end_date' => $end_date], true);
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 对微信小程序用户加密数据的解密示例代码
|
||||
* Class WXBizDataCrypt
|
||||
* 对微信小程序用户加密数据的解密示例代码.
|
||||
*
|
||||
* @copyright Copyright (c) 1998-2014 Tencent Inc.
|
||||
*/
|
||||
|
||||
|
||||
class WXBizDataCrypt
|
||||
{
|
||||
private $appid;
|
||||
@ -33,25 +35,24 @@ class WXBizDataCrypt
|
||||
public function decryptData($encryptedData, $iv, &$data)
|
||||
{
|
||||
if (strlen($this->sessionKey) != 24) {
|
||||
return ErrorCode::$IllegalAesKey;
|
||||
return \ErrorCode::$IllegalAesKey;
|
||||
}
|
||||
$aesKey = base64_decode($this->sessionKey);
|
||||
if (strlen($iv) != 24) {
|
||||
return ErrorCode::$IllegalIv;
|
||||
return \ErrorCode::$IllegalIv;
|
||||
}
|
||||
$aesIV = base64_decode($iv);
|
||||
$aesCipher = base64_decode($encryptedData);
|
||||
$result = openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
|
||||
$dataObj = json_decode($result);
|
||||
if ($dataObj == null) {
|
||||
return ErrorCode::$IllegalBuffer;
|
||||
return \ErrorCode::$IllegalBuffer;
|
||||
}
|
||||
// 兼容新版本无 watermark 的情况
|
||||
if (isset($dataObj->watermark) && $dataObj->watermark->appid != $this->appid) {
|
||||
return ErrorCode::$IllegalBuffer;
|
||||
if ($dataObj->watermark->appid != $this->appid) {
|
||||
return \ErrorCode::$IllegalBuffer;
|
||||
}
|
||||
$data = $result;
|
||||
return ErrorCode::$OK;
|
||||
return \ErrorCode::$OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,20 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
@ -25,7 +23,7 @@ use WeChat\Exceptions\InvalidResponseException;
|
||||
* Class Bill
|
||||
* @package WePay
|
||||
*/
|
||||
class Bill extends BasicWePay
|
||||
class Bill extends BasicPay
|
||||
{
|
||||
/**
|
||||
* 下载对账单
|
||||
@ -33,7 +31,6 @@ class Bill extends BasicWePay
|
||||
* @param null|string $outType 输出类型
|
||||
* @return bool|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function download(array $options, $outType = null)
|
||||
{
|
||||
@ -41,7 +38,7 @@ class Bill extends BasicWePay
|
||||
$params = $this->params->merge($options);
|
||||
$params['sign'] = $this->getPaySign($params, 'MD5');
|
||||
$result = Tools::post('https://api.mch.weixin.qq.com/pay/downloadbill', Tools::arr2xml($params));
|
||||
if (is_array($jsonData = Tools::xml3arr($result))) {
|
||||
if (($jsonData = Tools::xml2arr($result))) {
|
||||
if ($jsonData['return_code'] !== 'SUCCESS') {
|
||||
throw new InvalidResponseException($jsonData['return_msg'], '0');
|
||||
}
|
||||
@ -55,7 +52,6 @@ class Bill extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function comment(array $options)
|
||||
{
|
||||
|
@ -3,39 +3,36 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
|
||||
/**
|
||||
* 微信商户代金券
|
||||
* Class Coupon
|
||||
* @package WePay
|
||||
*/
|
||||
class Coupon extends BasicWePay
|
||||
class Coupon extends BasicPay
|
||||
{
|
||||
/**
|
||||
* 发放代金券
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $options)
|
||||
{
|
||||
$url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/send_coupon";
|
||||
return $this->callPostApi($url, $options, true, 'MD5');
|
||||
return $this->callPostApi($url, $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,7 +40,6 @@ class Coupon extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryStock(array $options)
|
||||
{
|
||||
@ -56,7 +52,6 @@ class Coupon extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryInfo(array $options)
|
||||
{
|
||||
|
@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
|
||||
/**
|
||||
* 微信扩展上报海关
|
||||
* Class Custom
|
||||
* @package WePay
|
||||
*/
|
||||
class Custom extends BasicWePay
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单附加信息提交接口
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function add(array $options = [])
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclareorder';
|
||||
return $this->callPostApi($url, $options, false, 'MD5', false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单附加信息查询接口
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function get(array $options = [])
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/customs/customdeclarequery';
|
||||
return $this->callPostApi($url, $options, false, 'MD5', true, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单附加信息重推接口
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function reset(array $options = [])
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/cgi-bin/mch/newcustoms/customdeclareredeclare';
|
||||
return $this->callPostApi($url, $options, false, 'MD5', true, false);
|
||||
}
|
||||
|
||||
}
|
@ -3,20 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Contracts\Tools;
|
||||
|
||||
/**
|
||||
@ -24,7 +22,7 @@ use WeChat\Contracts\Tools;
|
||||
* Class Order
|
||||
* @package WePay
|
||||
*/
|
||||
class Order extends BasicWePay
|
||||
class Order extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
@ -32,7 +30,6 @@ class Order extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $options)
|
||||
{
|
||||
@ -40,25 +37,11 @@ class Order extends BasicWePay
|
||||
return $this->callPostApi($url, $options, false, 'MD5');
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷卡支付
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function micropay(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/micropay';
|
||||
return $this->callPostApi($url, $options, false, 'MD5');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query(array $options)
|
||||
{
|
||||
@ -71,7 +54,6 @@ class Order extends BasicWePay
|
||||
* @param string $outTradeNo 商户订单号
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function close($outTradeNo)
|
||||
{
|
||||
@ -115,31 +97,11 @@ class Order extends BasicWePay
|
||||
return "weixin://wxpay/bizpayurl?" . http_build_query($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信App支付秘需参数
|
||||
* @param string $prepayId 统一下单预支付码
|
||||
* @return array
|
||||
*/
|
||||
public function appParams($prepayId)
|
||||
{
|
||||
$data = [
|
||||
'appid' => $this->config->get('appid'),
|
||||
'partnerid' => $this->config->get('mch_id'),
|
||||
'prepayid' => (string)$prepayId,
|
||||
'package' => 'Sign=WXPay',
|
||||
'timestamp' => (string)time(),
|
||||
'noncestr' => Tools::createNoncestr(),
|
||||
];
|
||||
$data['sign'] = $this->getPaySign($data, 'MD5');
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷卡支付 撤销订单
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function reverse(array $options)
|
||||
{
|
||||
@ -152,12 +114,11 @@ class Order extends BasicWePay
|
||||
* @param string $authCode 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function queryAuthCode($authCode)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/tools/authcodetoopenid';
|
||||
return $this->callPostApi($url, ['auth_code' => $authCode], false, 'MD5', false);
|
||||
return $this->callPostApi($url, ['auth_code' => $authCode]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +126,6 @@ class Order extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function report(array $options)
|
||||
{
|
||||
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
|
||||
/**
|
||||
* 微信分账
|
||||
* Class ProfitSharing
|
||||
* @package WePay
|
||||
*/
|
||||
class ProfitSharing extends BasicWePay
|
||||
{
|
||||
|
||||
/**
|
||||
* 请求单次分账
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharing(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharing';
|
||||
return $this->callPostApi($url, $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求多次分账
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function multiProfitSharing(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing';
|
||||
return $this->callPostApi($url, $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分账结果
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingQuery(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/profitsharingquery';
|
||||
return $this->callPostApi($url, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加分账接收方
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingAddReceiver(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver';
|
||||
return $this->callPostApi($url, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分账接收方
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingRemoveReceiver(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver';
|
||||
return $this->callPostApi($url, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完结分账
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingFinish(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish';
|
||||
return $this->callPostApi($url, $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单待分账金额
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingOrderAmountQuery(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/profitsharingorderamountquery';
|
||||
return $this->callPostApi($url, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分账回退
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingReturn(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/secapi/pay/profitsharingreturn';
|
||||
return $this->callPostApi($url, $options, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回退结果查询
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function profitSharingReturnQuery(array $options)
|
||||
{
|
||||
$url = 'https://api.mch.weixin.qq.com/pay/profitsharingreturnquery';
|
||||
return $this->callPostApi($url, $options);
|
||||
}
|
||||
}
|
@ -3,27 +3,25 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
|
||||
/**
|
||||
* 微信红包支持
|
||||
* Class Redpack
|
||||
* @package WePay
|
||||
*/
|
||||
class Redpack extends BasicWePay
|
||||
class Redpack extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
@ -31,7 +29,6 @@ class Redpack extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $options)
|
||||
{
|
||||
@ -46,7 +43,6 @@ class Redpack extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function groups(array $options)
|
||||
{
|
||||
@ -61,7 +57,6 @@ class Redpack extends BasicWePay
|
||||
* @param string $mchBillno 商户发放红包的商户订单号
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($mchBillno)
|
||||
{
|
||||
|
@ -3,22 +3,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidDecryptException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
/**
|
||||
@ -26,7 +23,7 @@ use WeChat\Exceptions\InvalidResponseException;
|
||||
* Class Refund
|
||||
* @package WePay
|
||||
*/
|
||||
class Refund extends BasicWePay
|
||||
class Refund extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
@ -34,7 +31,6 @@ class Refund extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $options)
|
||||
{
|
||||
@ -47,7 +43,6 @@ class Refund extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query(array $options)
|
||||
{
|
||||
@ -57,25 +52,25 @@ class Refund extends BasicWePay
|
||||
|
||||
/**
|
||||
* 获取退款通知
|
||||
* @param string|array $xml
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function getNotify($xml = '')
|
||||
public function getNotify()
|
||||
{
|
||||
$data = is_array($xml) ? $xml : Tools::xml2arr(empty($xml) ? Tools::getRawInput() : $xml);
|
||||
$data = Tools::xml2arr(file_get_contents("php://input"));
|
||||
if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') {
|
||||
throw new InvalidResponseException('获取退款通知XML失败!');
|
||||
}
|
||||
try {
|
||||
$key = md5($this->config->get('mch_key'));
|
||||
$decrypt = base64_decode($data['req_info']);
|
||||
$response = openssl_decrypt($decrypt, 'aes-256-ecb', $key, OPENSSL_RAW_DATA);
|
||||
$data['result'] = Tools::xml2arr($response);
|
||||
return $data;
|
||||
} catch (\Exception $exception) {
|
||||
throw new InvalidDecryptException($exception->getMessage(), $exception->getCode());
|
||||
if (!class_exists('Prpcrypt', false)) {
|
||||
include dirname(__DIR__) . '/WeChat/Contracts/Prpcrypt.php';
|
||||
}
|
||||
$pc = new \Prpcrypt(md5($this->config->get('mch_key')));
|
||||
$array = $pc->decrypt(base64_decode($data['req_info']));
|
||||
if (intval($array[0]) > 0) {
|
||||
throw new InvalidResponseException($array[1], $array[0]);
|
||||
}
|
||||
$data['decode'] = $array[1];
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
@ -3,27 +3,25 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
|
||||
/**
|
||||
* 微信商户打款到零钱
|
||||
* Class Transfers
|
||||
* @package WePay
|
||||
*/
|
||||
class Transfers extends BasicWePay
|
||||
class Transfers extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
@ -31,7 +29,6 @@ class Transfers extends BasicWePay
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function create(array $options)
|
||||
{
|
||||
@ -48,7 +45,6 @@ class Transfers extends BasicWePay
|
||||
* @param string $partnerTradeNo 商户调用企业付款API时使用的商户订单号
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($partnerTradeNo)
|
||||
{
|
||||
|
@ -3,20 +3,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePay;
|
||||
|
||||
use WeChat\Contracts\BasicWePay;
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidArgumentException;
|
||||
use WeChat\Exceptions\InvalidDecryptException;
|
||||
@ -27,7 +25,7 @@ use WeChat\Exceptions\InvalidResponseException;
|
||||
* Class TransfersBank
|
||||
* @package WePay
|
||||
*/
|
||||
class TransfersBank extends BasicWePay
|
||||
class TransfersBank extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
@ -70,7 +68,7 @@ class TransfersBank extends BasicWePay
|
||||
* 商户企业付款到银行卡操作进行结果查询
|
||||
* @param string $partnerTradeNo 商户订单号,需保持唯一
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function query($partnerTradeNo)
|
||||
@ -123,4 +121,5 @@ class TransfersBank extends BasicWePay
|
||||
Tools::setCache($cacheKey, $data['pub_key'], 600);
|
||||
return $data['pub_key'];
|
||||
}
|
||||
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
|
||||
// | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WePayV3;
|
||||
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WePayV3\Contracts\BasicWePay;
|
||||
use WePayV3\Contracts\DecryptAes;
|
||||
|
||||
/**
|
||||
* 平台证书管理
|
||||
* Class Cert
|
||||
* @package WePayV3
|
||||
*/
|
||||
class Cert extends BasicWePay
|
||||
{
|
||||
|
||||
/**
|
||||
* 自动配置平台证书
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoCert = false;
|
||||
|
||||
/**
|
||||
* 商户平台下载证书
|
||||
* @return void
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
try {
|
||||
$aes = new DecryptAes($this->config['mch_v3_key']);
|
||||
$result = $this->doRequest('GET', '/v3/certificates');
|
||||
$certs = [];
|
||||
foreach ($result['data'] as $vo) {
|
||||
$certs[$vo['serial_no']] = [
|
||||
'expire' => strtotime($vo['expire_time']),
|
||||
'content' => $aes->decryptToString(
|
||||
$vo['encrypt_certificate']['associated_data'],
|
||||
$vo['encrypt_certificate']['nonce'],
|
||||
$vo['encrypt_certificate']['ciphertext']
|
||||
)
|
||||
];
|
||||
}
|
||||
$this->tmpFile("{$this->config['mch_id']}_certs", $certs);
|
||||
} catch (\Exception $exception) {
|
||||
throw new InvalidResponseException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WePayV3;
|
||||
|
||||
use WePayV3\Contracts\BasicWePay;
|
||||
|
||||
/**
|
||||
* 普通商户消费者投诉2.0
|
||||
* @class Complaints
|
||||
* @package WePayV3
|
||||
*/
|
||||
class Complaints extends BasicWePay
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询投诉列表
|
||||
* @param int $offset 分页开始位置
|
||||
* @param int $limit 分页大小
|
||||
* @param String $begin_date 开始日期
|
||||
* @param String $end_date 结束日期
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function complaintList($offset, $limit, $begin_date, $end_date)
|
||||
{
|
||||
$mchId = $this->config['mch_id'];
|
||||
$pathinfo = "/v3/merchant-service/complaints-v2?limit={$limit}&offset={$offset}&begin_date={$begin_date}&end_date={$end_date}&complainted_mchid={$mchId}";
|
||||
return $this->doRequest('GET', $pathinfo, '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询投诉详情
|
||||
* @param string $complaint_id 被投诉单号
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function complaintDetails($complaint_id)
|
||||
{
|
||||
$pathinfo = "/v3/merchant-service/complaints-v2/{$complaint_id}";
|
||||
return $this->doRequest('GET', $pathinfo, '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询投诉协商历史
|
||||
* @param string $complaint_id 被投诉单号
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function negotiationHistory($complaint_id)
|
||||
{
|
||||
$pathinfo = "/v3/merchant-service/complaints-v2/{$complaint_id}/negotiation-historys";
|
||||
return $this->doRequest('GET', $pathinfo, '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建投诉通知回调地址
|
||||
* @param string $url 回调通知地址
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function CreateComplaintsNotify($url)
|
||||
{
|
||||
return $this->doRequest('POST', '/v3/merchant-service/complaint-notifications', json_encode(['url' => $url], JSON_UNESCAPED_UNICODE), true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询投诉通知回调地址
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function queryComplaintsNotify()
|
||||
{
|
||||
return $this->doRequest('GET', '/v3/merchant-service/complaint-notifications', '', true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新投诉通知回调地址
|
||||
* @param string $url 回调通知地址
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function updateComplaintsNotify($url)
|
||||
{
|
||||
return $this->doRequest('PUT', '/v3/merchant-service/complaint-notifications', json_encode(['url' => $url], JSON_UNESCAPED_UNICODE), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除投诉通知回调地址
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function deleteComplaintsNotify()
|
||||
{
|
||||
return $this->doRequest('DELETE', '/v3/merchant-service/complaint-notifications', '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复投诉
|
||||
* @param string $complaint_id 被投诉单号
|
||||
* @param array $content 回复内容
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function replyInfo($complaint_id, array $content)
|
||||
{
|
||||
$content['complainted_mchid'] = $this->config['mch_id'];
|
||||
$pathinfo = "/v3/merchant-service/complaints-v2/{$complaint_id}/response";
|
||||
return $this->doRequest('POST', $pathinfo, json_encode($content, JSON_UNESCAPED_UNICODE), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反馈处理完成
|
||||
* @param string $complaint_id 被投诉单号
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function completeComplaints($complaint_id)
|
||||
{
|
||||
$mchId = $this->config['mch_id'];
|
||||
$pathinfo = "/v3/merchant-service/complaints-v2/{$complaint_id}/complete";
|
||||
return $this->doRequest('POST', $pathinfo, json_encode(['complainted_mchid' => $mchId], JSON_UNESCAPED_UNICODE), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片请求接口
|
||||
* @param string $pathinfo
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function downLoadImg($pathinfo)
|
||||
{
|
||||
return $this->doRequest('GET', $pathinfo, '', true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片上传接口
|
||||
* @param array $imginfo
|
||||
* @return array|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function uploadImg(array $imginfo)
|
||||
{
|
||||
return $this->doRequest('POST', '/v3/merchant-service/images/upload', json_encode($imginfo, JSON_UNESCAPED_UNICODE), true);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user