mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-05 01:42:45 +08:00
[更新]获取二进制资源接口增加重试
This commit is contained in:
parent
d6b86979ac
commit
9464d20af4
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,4 +5,5 @@
|
||||
/Cache
|
||||
/Test/cert
|
||||
/nbproject
|
||||
/composer.lock
|
||||
/composer.lock
|
||||
/_test/cert
|
2
We.php
2
We.php
@ -74,7 +74,7 @@ class We
|
||||
* 定义当前版本
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '1.2.9';
|
||||
const VERSION = '1.2.12';
|
||||
|
||||
/**
|
||||
* 静态配置
|
||||
|
@ -40,19 +40,19 @@ class BasicWeChat
|
||||
* 当前请求方法参数
|
||||
* @var array
|
||||
*/
|
||||
private $currentMethod = [];
|
||||
protected $currentMethod = [];
|
||||
|
||||
/**
|
||||
* 当前模式
|
||||
* @var bool
|
||||
*/
|
||||
private $isTry = false;
|
||||
protected $isTry = false;
|
||||
|
||||
/**
|
||||
* 注册代替函数
|
||||
* @var string
|
||||
*/
|
||||
private $GetAccessTokenCallback;
|
||||
protected $GetAccessTokenCallback;
|
||||
|
||||
/**
|
||||
* BasicWeChat constructor.
|
||||
@ -128,7 +128,7 @@ class BasicWeChat
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理删除accessToken
|
||||
* 清理删除 AccessToken
|
||||
* @return bool
|
||||
*/
|
||||
public function delAccessToken()
|
||||
|
@ -1,17 +1,5 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Contracts;
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ class Custom extends BasicWeChat
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
* @throws Exceptions\LocalCacheException
|
||||
*/
|
||||
public function inviteworker($kf_account, $invite_wx)
|
||||
public function inviteWorker($kf_account, $invite_wx)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
|
@ -56,7 +56,11 @@ class Media extends BasicWeChat
|
||||
$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());
|
||||
$result = Tools::get($url);
|
||||
if (json_decode($result)) {
|
||||
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);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
@ -139,7 +143,11 @@ class Media extends BasicWeChat
|
||||
$url = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN";
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$result = Tools::post($url, ['media_id' => $media_id]);
|
||||
if (json_decode($result)) {
|
||||
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);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
|
@ -160,6 +160,7 @@ class Pay extends BasicWePay
|
||||
* @param array $options 静音参数
|
||||
* @param null|string $outType 输出类型
|
||||
* @return bool|string
|
||||
* @throws Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function billDownload(array $options, $outType = null)
|
||||
|
@ -16,6 +16,7 @@ namespace WeMini;
|
||||
|
||||
use WeChat\Contracts\BasicWeChat;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
|
||||
/**
|
||||
* 微信小程序二维码管理
|
||||
@ -44,7 +45,11 @@ class Qrcode extends BasicWeChat
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$data = ['path' => $path, 'width' => $width, 'auto_color' => $auto_color, 'line_color' => $line_color, 'is_hyaline' => $is_hyaline];
|
||||
$result = Tools::post($url, Tools::arr2json($data));
|
||||
if (json_decode($result)) {
|
||||
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);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
@ -70,7 +75,11 @@ class Qrcode extends BasicWeChat
|
||||
$data = ['scene' => $scene, 'width' => $width, 'auto_color' => $auto_color, 'page' => $page, 'line_color' => $line_color, 'is_hyaline' => $is_hyaline];
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$result = Tools::post($url, Tools::arr2json($data));
|
||||
if (json_decode($result)) {
|
||||
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);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
@ -91,7 +100,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());
|
||||
$result = Tools::post($url, Tools::arr2json(['path' => $path, 'width' => $width]));
|
||||
if (json_decode($result)) {
|
||||
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);
|
||||
}
|
||||
return is_null($outType) ? $result : $outType($result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user