ComposerUpdate

This commit is contained in:
Anyon 2020-07-22 14:42:20 +08:00
parent 1df53abef0
commit 4e8c9fad6e
19 changed files with 91 additions and 227 deletions

View File

@ -11,6 +11,9 @@
{block name='content'}
<div class="think-box-shadow table-block">
<p class=" margin-bottom-15">
演示接口文档:<a target="_blank" href="http://www.docway.net/project/1WkI0ZyQ7M1/share/1Wld0z7b1zE">http://www.docway.net/project/1WkI0ZyQ7M1/share/1Wld0z7b1zE</a>
</p>
{include file='article_content/index_search'}
<table class="layui-table margin-top-10" lay-skin="line">
{notempty name='list'}

View File

@ -14,6 +14,9 @@
{block name='content'}
<div class="think-box-shadow">
<p class=" margin-bottom-15">
演示接口文档:<a target="_blank" href="http://www.docway.net/project/1WkI0ZyQ7M1/share/1Wld0z7b1zE">http://www.docway.net/project/1WkI0ZyQ7M1/share/1Wld0z7b1zE</a>
</p>
{include file='article_tags/index_search'}
<table class="layui-table margin-top-10" lay-skin="line">
{notempty name='list'}

18
composer.lock generated
View File

@ -929,12 +929,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "84f463dd9e1f30421c430f570c0abde3861c4959"
"reference": "e03639f80bccd83c9ab5bb1f1001ea1d62d85afa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/84f463dd9e1f30421c430f570c0abde3861c4959",
"reference": "84f463dd9e1f30421c430f570c0abde3861c4959",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e03639f80bccd83c9ab5bb1f1001ea1d62d85afa",
"reference": "e03639f80bccd83c9ab5bb1f1001ea1d62d85afa",
"shasum": "",
"mirrors": [
{
@ -978,20 +978,20 @@
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top",
"time": "2020-07-17T08:39:58+00:00"
"time": "2020-07-22T06:32:55+00:00"
},
{
"name": "zoujingli/wechat-developer",
"version": "v1.2.22",
"version": "v1.2.23",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/WeChatDeveloper.git",
"reference": "7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059"
"reference": "f070dd076a4137ff4e86600b63d1ccfe2f744a92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059",
"reference": "7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/f070dd076a4137ff4e86600b63d1ccfe2f744a92",
"reference": "f070dd076a4137ff4e86600b63d1ccfe2f744a92",
"shasum": "",
"mirrors": [
{
@ -1044,7 +1044,7 @@
"wechatpay",
"wepay"
],
"time": "2020-07-04T07:24:41+00:00"
"time": "2020-07-20T06:55:26+00:00"
}
],
"packages-dev": [],

View File

@ -263,7 +263,6 @@ return array(
'think\\admin\\Exception' => $vendorDir . '/zoujingli/think-library/src/Exception.php',
'think\\admin\\Helper' => $vendorDir . '/zoujingli/think-library/src/Helper.php',
'think\\admin\\Library' => $vendorDir . '/zoujingli/think-library/src/Library.php',
'think\\admin\\Module' => $vendorDir . '/zoujingli/think-library/src/Module.php',
'think\\admin\\Queue' => $vendorDir . '/zoujingli/think-library/src/Queue.php',
'think\\admin\\Service' => $vendorDir . '/zoujingli/think-library/src/Service.php',
'think\\admin\\Storage' => $vendorDir . '/zoujingli/think-library/src/Storage.php',

View File

@ -396,7 +396,6 @@ class ComposerStaticInitb911c14a0826c73d9f097343fd33a252
'think\\admin\\Exception' => __DIR__ . '/..' . '/zoujingli/think-library/src/Exception.php',
'think\\admin\\Helper' => __DIR__ . '/..' . '/zoujingli/think-library/src/Helper.php',
'think\\admin\\Library' => __DIR__ . '/..' . '/zoujingli/think-library/src/Library.php',
'think\\admin\\Module' => __DIR__ . '/..' . '/zoujingli/think-library/src/Module.php',
'think\\admin\\Queue' => __DIR__ . '/..' . '/zoujingli/think-library/src/Queue.php',
'think\\admin\\Service' => __DIR__ . '/..' . '/zoujingli/think-library/src/Service.php',
'think\\admin\\Storage' => __DIR__ . '/..' . '/zoujingli/think-library/src/Storage.php',

View File

@ -955,12 +955,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "84f463dd9e1f30421c430f570c0abde3861c4959"
"reference": "e03639f80bccd83c9ab5bb1f1001ea1d62d85afa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/84f463dd9e1f30421c430f570c0abde3861c4959",
"reference": "84f463dd9e1f30421c430f570c0abde3861c4959",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/e03639f80bccd83c9ab5bb1f1001ea1d62d85afa",
"reference": "e03639f80bccd83c9ab5bb1f1001ea1d62d85afa",
"shasum": "",
"mirrors": [
{
@ -976,7 +976,7 @@
"ext-json": "*",
"topthink/framework": "^6.0"
},
"time": "2020-07-17T08:39:58+00:00",
"time": "2020-07-22T06:32:55+00:00",
"type": "library",
"extra": {
"think": {
@ -1009,17 +1009,17 @@
},
{
"name": "zoujingli/wechat-developer",
"version": "v1.2.22",
"version_normalized": "1.2.22.0",
"version": "v1.2.23",
"version_normalized": "1.2.23.0",
"source": {
"type": "git",
"url": "https://github.com/zoujingli/WeChatDeveloper.git",
"reference": "7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059"
"reference": "f070dd076a4137ff4e86600b63d1ccfe2f744a92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059",
"reference": "7eb7f6a2d8aa4a105208c7dff6428dcecd0c7059",
"url": "https://api.github.com/repos/zoujingli/WeChatDeveloper/zipball/f070dd076a4137ff4e86600b63d1ccfe2f744a92",
"reference": "f070dd076a4137ff4e86600b63d1ccfe2f744a92",
"shasum": "",
"mirrors": [
{
@ -1039,7 +1039,7 @@
"ext-xml": "*",
"php": ">=5.4"
},
"time": "2020-07-04T07:24:41+00:00",
"time": "2020-07-20T06:55:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-07-20 10:35:09
// This file is automatically generated at:2020-07-22 14:38:21
declare (strict_types = 1);
return array (
0 => 'think\\app\\Service',

View File

@ -1,113 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/ThinkLibrary
// | github 代码仓库https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
namespace think\admin;
use ZipArchive;
/**
* 应用模块安装服务
* Class Module
* @package think\admin
*/
abstract class Module extends Service
{
abstract public function getName();
abstract public function getTitle();
abstract public function getRemark();
abstract public function getVersion();
abstract public function callUpdate();
abstract public function callInstall();
/**
* 安装应用模块
* @param ZipArchive $zip 安装包
* @return array
*/
protected function _install(ZipArchive $zip): array
{
// 安装包检查
list($state, $message) = $this->_checkzip($zip);
if (empty($state)) return [$state, $message];
// 执行文件安装
if ($zip->extractTo($this->app->getBasePath() . $this->getName())) {
return [1, '应用模块安装成功'];
} else {
return [0, '应用模块安装失败'];
}
}
/**
* 移除应用模块
* @return array
*/
protected function _remove(): array
{
$directory = $this->app->getBasePath() . $this->getName();
if (file_exists($directory) && is_dir($directory)) {
return [0, '提交移除应用模块指令成功'];
} else {
return [1, '待删除的应用模块不存在'];
}
}
/**
* 检测安装包是否正常
* @param ZipArchive $zip 安装包
* @return array
*/
protected function _checkzip(ZipArchive $zip): array
{
$directory = "{$zip->filename}.files";
file_exists($directory) || mkdir($directory, 0755, true);
// 尝试解压应用包
if ($zip->extractTo($directory) === false) {
return [0, '应用模块压缩文件解压失败'];
}
// 检测应用配置文件
$info = @include($directory . DIRECTORY_SEPARATOR . 'app.php');
// 删除临时解压的文件
$this->_forceRemove($directory);
// 返回应用模块检查结果
if (empty($info)) {
return [0, '未获取到应用模块配置信息'];
} elseif ($info['name'] !== $this->getName()) {
return [0, '应用模块名称与注册名称不一致'];
} else {
return [1, '应用模块基础检查通过'];
}
}
/**
* 强制删除指定的目录
* @param string $directory
*/
private function _forceRemove(string $directory)
{
if (file_exists($directory) && is_dir($directory) && $handle = opendir($directory)) {
while (false !== ($item = readdir($handle))) if (!in_array($item, ['.', '..'])) {
$this->_forceRemove("{$directory}/{$item}");
}
[closedir($handle), rmdir($directory)];
} else {
file_exists($directory) && is_file($directory) && @unlink($directory);
}
}
}

View File

@ -88,7 +88,7 @@ abstract class Storage
*/
public static function __callStatic($method, $arguments)
{
if (method_exists($class = self::instance(), $method)) {
if (method_exists($class = static::instance(), $method)) {
return call_user_func_array([$class, $method], $arguments);
} else {
throw new Exception("method not exists: " . get_class($class) . "->{$method}()");
@ -141,13 +141,13 @@ abstract class Storage
{
try {
$file = LocalStorage::instance();
$name = self::name($url, '', 'down/');
$name = static::name($url, '', 'down/');
if (empty($force) && $file->has($name)) {
if ($expire < 1 || filemtime($file->path($name)) + $expire > time()) {
return $file->info($name);
}
}
return $file->set($name, self::getCurl($url));
return $file->set($name, static::curlGet($url));
} catch (\Exception $exception) {
return ['url' => $url, 'hash' => md5($url), 'key' => $url, 'file' => $url];
}
@ -161,7 +161,7 @@ abstract class Storage
*/
public static function mime($exts, $mime = [])
{
$mimes = self::mimes();
$mimes = static::mimes();
foreach (is_string($exts) ? explode(',', $exts) : $exts as $ext) {
$mime[] = $mimes[strtolower($ext)] ?? 'application/octet-stream';
}
@ -184,7 +184,7 @@ abstract class Storage
* @param string $url
* @return string
*/
public static function getCurl($url)
public static function curlGet($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

View File

@ -51,7 +51,7 @@ class DataExtend
public static function arr2table(array $list, $cid = 'id', $pid = 'pid', $cpath = 'path', $ppath = '')
{
$tree = [];
foreach (self::arr2tree($list, $cid, $pid) as $attr) {
foreach (static::arr2tree($list, $cid, $pid) as $attr) {
$attr[$cpath] = "{$ppath}-{$attr[$cid]}";
$attr['sub'] = $attr['sub'] ?? [];
$attr['spt'] = substr_count($ppath, '-');
@ -59,7 +59,7 @@ class DataExtend
$sub = $attr['sub'];
unset($attr['sub']);
$tree[] = $attr;
if (!empty($sub)) $tree = array_merge($tree, self::arr2table($sub, $cid, $pid, $cpath, $attr[$cpath]));
if (!empty($sub)) $tree = array_merge($tree, static::arr2table($sub, $cid, $pid, $cpath, $attr[$cpath]));
}
return $tree;
}
@ -76,7 +76,7 @@ class DataExtend
{
$ids = [intval($id)];
foreach ($list as $vo) if (intval($vo[$pkey]) > 0 && intval($vo[$pkey]) === intval($id)) {
$ids = array_merge($ids, self::getArrSubIds($list, intval($vo[$key]), $key, $pkey));
$ids = array_merge($ids, static::getArrSubIds($list, intval($vo[$key]), $key, $pkey));
}
return $ids;
}

View File

@ -49,7 +49,7 @@ class ExcelExtend
foreach ($list as $data) {
$rows = [];
foreach ($rules as $rule) {
$rows[] = self::parseKeyDotValue($data, $rule);
$rows[] = static::parseKeyDotValue($data, $rule);
}
fputcsv($handle, $rows);
}

View File

@ -29,10 +29,10 @@ class HttpExtend
* @param array $options CURL请求参数
* @return boolean|string
*/
public static function get($location, $query = [], $options = [])
public static function get($location, $query = [], array $options = [])
{
$options['query'] = $query;
return self::request('get', $location, $options);
return static::request('get', $location, $options);
}
/**
@ -42,10 +42,10 @@ class HttpExtend
* @param array $options CURL请求参数
* @return boolean|string
*/
public static function post($location, $data = [], $options = [])
public static function post($location, $data = [], array $options = [])
{
$options['data'] = $data;
return self::request('post', $location, $options);
return static::request('post', $location, $options);
}
/**
@ -60,27 +60,41 @@ class HttpExtend
*/
public static function submit($url, array $data = [], array $file = [], array $header = [], $method = 'POST', $returnHeader = true)
{
list($boundary, $content) = self::buildFormData($data, $file);
list($line, $boundary) = [[], CodeExtend::random(18)];
foreach ($data as $key => $value) {
$line[] = "--{$boundary}";
$line[] = "Content-Disposition: form-data; name=\"{$key}\"";
$line[] = "";
$line[] = $value;
}
if (is_array($file) && isset($file['field']) && isset($file['name'])) {
$line[] = "--{$boundary}";
$line[] = "Content-Disposition: form-data; name=\"{$file['field']}\"; filename=\"{$file['name']}\"";
$line[] = "";
$line[] = $file['content'];
}
$line[] = "--{$boundary}--";
$header[] = "Content-type:multipart/form-data;boundary={$boundary}";
return self::request($method, $url, ['data' => $content, 'returnHeader' => $returnHeader, 'headers' => $header]);
return static::request($method, $url, ['data' => join("\r\n", $line), 'returnHeader' => $returnHeader, 'headers' => $header]);
}
/**
* CURL模拟网络请求
* @param string $method 请求方法
* @param string $location 请求地址
* @param array $options 请求参数[headers,data,cookie,cookie_file,timeout,returnHeader]
* CURL 模拟网络请求
* @param string $method 模拟请求方式
* @param string $location 模拟请求地址
* @param array $options 请求参数[headers,query,data,cookie,cookie_file,timeout,returnHeader]
* @return boolean|string
*/
public static function request($method, $location, $options = [])
public static function request($method, $location, array $options = [])
{
$curl = curl_init();
// GET 参数设置
if (!empty($options['query'])) {
$location .= (stripos($location, '?') !== false ? '&' : '?') . http_build_query($options['query']);
$split = strpos($location, '?') !== false ? '&' : '?';
$location .= $split . http_build_query($options['query']);
}
// 浏览器代理设置
curl_setopt($curl, CURLOPT_USERAGENT, self::getUserAgent());
$curl = curl_init();
// Agent 代理设置
curl_setopt($curl, CURLOPT_USERAGENT, static::getUserAgent());
// CURL 头信息设置
if (!empty($options['headers'])) {
curl_setopt($curl, CURLOPT_HTTPHEADER, $options['headers']);
@ -98,7 +112,8 @@ class HttpExtend
if (strtolower($method) === 'head') {
curl_setopt($curl, CURLOPT_NOBODY, 1);
} elseif (isset($options['data'])) {
curl_setopt($curl, CURLOPT_POSTFIELDS, self::buildQueryData($options['data']));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $options['data']);
}
// 请求超时设置
if (isset($options['timeout']) && is_numeric($options['timeout'])) {
@ -106,6 +121,7 @@ class HttpExtend
} else {
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
}
// 是否返回前部内容
if (empty($options['returnHeader'])) {
curl_setopt($curl, CURLOPT_HEADER, false);
} else {
@ -118,55 +134,10 @@ class HttpExtend
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);
[$content] = [curl_exec($curl), curl_close($curl)];
return $content;
}
/**
* POST 数据过滤处理
* @param array $data 需要处理的数据
* @param boolean $build 是否编译数据
* @return array|string
*/
private static function buildQueryData($data, $build = true)
{
if (!is_array($data)) return $data;
foreach ($data as $key => $value) {
if (is_string($value) && stripos($value, '@') === 0 && class_exists('CURLFile')) {
if (file_exists($filename = realpath(ltrim($value, '@')))) {
list($build, $data[$key]) = [false, new \CURLFile($filename)];
}
} elseif ($value instanceof \CURLFile) $build = false;
}
return $build ? http_build_query($data) : $data;
}
/**
* 生成 FormData 格式数据内容
* @param array $data 表单提交的数据
* @param array $file 表单上传的文件
* @return array
*/
private static function buildFormData(array $data = [], array $file = [])
{
list($line, $boundary) = [[], CodeExtend::random(18)];
foreach ($data as $key => $value) {
$line[] = "--{$boundary}";
$line[] = "Content-Disposition: form-data; name=\"{$key}\"";
$line[] = "";
$line[] = $value;
}
if (is_array($file) && isset($file['field']) && isset($file['name'])) {
$line[] = "--{$boundary}";
$line[] = "Content-Disposition: form-data; name=\"{$file['field']}\"; filename=\"{$file['name']}\"";
$line[] = "";
$line[] = $file['content'];
}
$line[] = "--{$boundary}--";
return [$boundary, join("\r\n", $line)];
}
/**
* 获取浏览器代理信息
* @return string
@ -174,7 +145,7 @@ class HttpExtend
private static function getUserAgent()
{
if (!empty($_SERVER['HTTP_USER_AGENT'])) return $_SERVER['HTTP_USER_AGENT'];
$aligs = [
$agents = [
"Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11",
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",
@ -185,6 +156,6 @@ class HttpExtend
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
];
return $aligs[array_rand($aligs, 1)];
return $agents[array_rand($agents, 1)];
}
}

View File

@ -90,7 +90,7 @@ class QueueService extends Service
throw new \think\admin\Exception("Qeueu reset failed, Queue {$this->code} data cannot be empty!");
}
$this->app->db->name('SystemQueue')->where(['code' => $this->code])->strict(false)->failException(true)->update([
'exec_pid' => '0', 'exec_time' => time() + $wait, 'status' => '1',
'exec_pid' => 0, 'exec_time' => time() + $wait, 'status' => 1,
]);
return $this->initialize($this->code);
}
@ -124,7 +124,7 @@ class QueueService extends Service
*/
public function register($title, $command, $later = 0, $data = [], $rscript = 0, $loops = 0)
{
$map = [['title', '=', $title], ['status', 'in', ['1', '2']]];
$map = [['title', '=', $title], ['status', 'in', [1, 2]]];
if (empty($rscript) && ($queue = $this->app->db->name('SystemQueue')->where($map)->find())) {
throw new \think\admin\Exception(lang('think_library_queue_exist'), 0, $queue['code']);
}
@ -133,12 +133,12 @@ class QueueService extends Service
'code' => $this->code,
'title' => $title,
'command' => $command,
'attempts' => '0',
'attempts' => 0,
'rscript' => intval(boolval($rscript)),
'exec_data' => json_encode($data, JSON_UNESCAPED_UNICODE),
'exec_time' => $later > 0 ? time() + $later : time(),
'enter_time' => '0',
'outer_time' => '0',
'enter_time' => 0,
'outer_time' => 0,
'loops_time' => $loops,
]);
$this->progress(1, '>>> 任务创建成功 <<<', 0.00);

View File

@ -336,7 +336,7 @@ class SystemService extends Service
{
$data = $this->getRuntime();
$this->app->console->call('clear');
$this->setRuntime($data['map'], $data['run']);
$this->setRuntime($data['map'], $data['run'], $data['uri']);
}
/**

View File

@ -131,7 +131,7 @@ class AliossStorage extends Storage
*/
public function get($name, $safe = false)
{
return self::getCurl($this->url($name, $safe));
return static::curlGet($this->url($name, $safe));
}
/**

View File

@ -94,7 +94,7 @@ class LocalStorage extends Storage
public function get($name, $safe = false)
{
if (!$this->has($name, $safe)) return '';
return self::getCurl($this->path($name, $safe));
return static::curlGet($this->path($name, $safe));
}
/**

View File

@ -101,7 +101,7 @@ class QiniuStorage extends Storage
{
$url = $this->url($name, $safe) . "?e=" . time();
$token = "{$this->accessKey}:{$this->safeBase64(hash_hmac('sha1', $url, $this->secretKey, true))}";
return self::getCurl("{$url}&token={$token}");
return static::curlGet("{$url}&token={$token}");
}
/**

View File

@ -86,7 +86,7 @@ class We
* 定义当前版本
* @var string
*/
const VERSION = '1.2.22';
const VERSION = '1.2.23';
/**
* 静态配置

View File

@ -94,7 +94,7 @@ class BasicWeChat
}
/**
* 获取访问accessToken
* 获取访问 AccessToken
* @return string
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
@ -166,15 +166,15 @@ class BasicWeChat
{
try {
return Tools::json2arr(Tools::get($url));
} catch (InvalidResponseException $e) {
} catch (InvalidResponseException $exception) {
if (isset($this->currentMethod['method']) && empty($this->isTry)) {
if (in_array($e->getCode(), ['40014', '40001', '41001', '42001'])) {
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']);
}
}
throw new InvalidResponseException($e->getMessage(), $e->getCode());
throw new InvalidResponseException($exception->getMessage(), $exception->getCode());
}
}
@ -190,13 +190,15 @@ class BasicWeChat
protected function httpPostForJson($url, array $data, $buildToJson = true)
{
try {
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'])) {
$options = [];
if ($buildToJson) $options['headers'] = ['Content-Type: application/json'];
return Tools::json2arr(Tools::post($url, $buildToJson ? Tools::arr2json($data) : $data, $options));
} catch (InvalidResponseException $exception) {
if (!$this->isTry && 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']);
}
throw new InvalidResponseException($e->getMessage(), $e->getCode());
throw new InvalidResponseException($exception->getMessage(), $exception->getCode());
}
}