diff --git a/thinkphp/library/think/File.php b/thinkphp/library/think/File.php index 4bcf51652..dc597701c 100644 --- a/thinkphp/library/think/File.php +++ b/thinkphp/library/think/File.php @@ -242,8 +242,12 @@ class File extends SplFileObject if (function_exists('exif_imagetype')) { return exif_imagetype($image); } else { - $info = getimagesize($image); - return $info[2]; + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } } } diff --git a/thinkphp/library/think/Paginator.php b/thinkphp/library/think/Paginator.php index 39d2f6446..4f65840ed 100644 --- a/thinkphp/library/think/Paginator.php +++ b/thinkphp/library/think/Paginator.php @@ -141,7 +141,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J */ public static function getCurrentPage($varPage = 'page', $default = 1) { - $page = (int) Request::instance()->request($varPage); + $page = (int) Request::instance()->param($varPage); if (filter_var($page, FILTER_VALIDATE_INT) !== false && $page >= 1) { return $page; diff --git a/thinkphp/library/think/Validate.php b/thinkphp/library/think/Validate.php index 72b9307ba..c12ee6d1b 100644 --- a/thinkphp/library/think/Validate.php +++ b/thinkphp/library/think/Validate.php @@ -633,8 +633,12 @@ class Validate if (function_exists('exif_imagetype')) { return exif_imagetype($image); } else { - $info = getimagesize($image); - return $info[2]; + try { + $info = getimagesize($image); + return $info ? $info[2] : false; + } catch (\Exception $e) { + return false; + } } } diff --git a/thinkphp/library/think/db/Query.php b/thinkphp/library/think/db/Query.php index 108d12cc3..e03ad8a79 100644 --- a/thinkphp/library/think/db/Query.php +++ b/thinkphp/library/think/db/Query.php @@ -2399,7 +2399,7 @@ class Query { if (is_scalar($value)) { $data = $value; - } elseif (is_array($value) && 'eq' == strtolower($value[0])) { + } elseif (is_array($value) && is_string($value[0]) && 'eq' == strtolower($value[0])) { $data = $value[1]; } if (isset($data)) { diff --git a/thinkphp/library/think/db/connector/Mysql.php b/thinkphp/library/think/db/connector/Mysql.php index 536125fd1..9d146c713 100644 --- a/thinkphp/library/think/db/connector/Mysql.php +++ b/thinkphp/library/think/db/connector/Mysql.php @@ -31,12 +31,15 @@ class Mysql extends Connection */ protected function parseDsn($config) { - $dsn = 'mysql:dbname=' . $config['database'] . ';host=' . $config['hostname']; - if (!empty($config['hostport'])) { - $dsn .= ';port=' . $config['hostport']; - } elseif (!empty($config['socket'])) { - $dsn .= ';unix_socket=' . $config['socket']; + if (!empty($config['socket'])) { + $dsn = 'mysql:unix_socket=' . $config['socket']; + } elseif (!empty($config['hostport'])) { + $dsn = 'mysql:host=' . $config['hostname'] . ';port=' . $config['hostport']; + } else { + $dsn = 'mysql:host=' . $config['hostname']; } + $dsn .= ';dbname=' . $config['database']; + if (!empty($config['charset'])) { $dsn .= ';charset=' . $config['charset']; } diff --git a/thinkphp/library/think/model/Relation.php b/thinkphp/library/think/model/Relation.php index 4869e5261..19a06c100 100644 --- a/thinkphp/library/think/model/Relation.php +++ b/thinkphp/library/think/model/Relation.php @@ -108,7 +108,8 @@ abstract class Relation * @access protected * @return void */ - abstract protected function baseQuery(); + protected function baseQuery() + {} public function __call($method, $args) { diff --git a/thinkphp/library/think/model/relation/HasMany.php b/thinkphp/library/think/model/relation/HasMany.php index 6dbf9dd39..eb9bf66de 100644 --- a/thinkphp/library/think/model/relation/HasMany.php +++ b/thinkphp/library/think/model/relation/HasMany.php @@ -77,7 +77,7 @@ class HasMany extends Relation } if (!empty($range)) { - $data = $this->eagerlyOneToMany($this, [ + $data = $this->eagerlyOneToMany(new $this->model, [ $this->foreignKey => [ 'in', $range, @@ -114,7 +114,7 @@ class HasMany extends Relation $localKey = $this->localKey; if (isset($result->$localKey)) { - $data = $this->eagerlyOneToMany($this, [$this->foreignKey => $result->$localKey], $relation, $subRelation, $closure); + $data = $this->eagerlyOneToMany(new $this->model, [$this->foreignKey => $result->$localKey], $relation, $subRelation, $closure); // 关联数据封装 if (!isset($data[$result->$localKey])) { $data[$result->$localKey] = []; diff --git a/thinkphp/library/think/model/relation/MorphTo.php b/thinkphp/library/think/model/relation/MorphTo.php index df104a907..9136d78ed 100644 --- a/thinkphp/library/think/model/relation/MorphTo.php +++ b/thinkphp/library/think/model/relation/MorphTo.php @@ -271,11 +271,4 @@ class MorphTo extends Relation return $this->parent->setRelation($this->relation, null); } - /** - * 执行基础查询(进执行一次) - * @access protected - * @return void - */ - protected function baseQuery() - {} } diff --git a/thinkphp/library/think/model/relation/OneToOne.php b/thinkphp/library/think/model/relation/OneToOne.php index 7877eaaa3..9cf307a5d 100644 --- a/thinkphp/library/think/model/relation/OneToOne.php +++ b/thinkphp/library/think/model/relation/OneToOne.php @@ -311,11 +311,4 @@ abstract class OneToOne extends Relation return $data; } - /** - * 执行基础查询(进执行一次) - * @access protected - * @return void - */ - protected function baseQuery() - {} } diff --git a/thinkphp/library/traits/controller/Jump.php b/thinkphp/library/traits/controller/Jump.php index 761544c66..472f23d19 100644 --- a/thinkphp/library/traits/controller/Jump.php +++ b/thinkphp/library/traits/controller/Jump.php @@ -36,8 +36,8 @@ trait Jump */ protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = []) { - if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) { - $url = $_SERVER["HTTP_REFERER"]; + if (is_null($url) && !is_null(Request::instance()->server('HTTP_REFERER'))) { + $url = Request::instance()->server('HTTP_REFERER'); } elseif ('' !== $url) { $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : Url::build($url); } @@ -107,7 +107,7 @@ trait Jump $result = [ 'code' => $code, 'msg' => $msg, - 'time' => $_SERVER['REQUEST_TIME'], + 'time' => Request::instance()->server('REQUEST_TIME'), 'data' => $data, ]; $type = $type ?: $this->getResponseType(); diff --git a/vendor/autoload.php b/vendor/autoload.php index 8fc46a224..bb1a8d905 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef::getLoader(); +return ComposerAutoloaderInit3448f0100e342fbe3e650c8002f8599f::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index a17218e62..ec0b314f1 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef +class ComposerAutoloaderInit3448f0100e342fbe3e650c8002f8599f { private static $loader; @@ -19,15 +19,15 @@ class ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit3448f0100e342fbe3e650c8002f8599f', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit3448f0100e342fbe3e650c8002f8599f', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit3448f0100e342fbe3e650c8002f8599f::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ class ComposerAutoloaderInitbde5f15deccc7b20dfc55f50254913ef $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit3448f0100e342fbe3e650c8002f8599f::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirebde5f15deccc7b20dfc55f50254913ef($fileIdentifier, $file); + composerRequire3448f0100e342fbe3e650c8002f8599f($fileIdentifier, $file); } return $loader; } } -function composerRequirebde5f15deccc7b20dfc55f50254913ef($fileIdentifier, $file) +function composerRequire3448f0100e342fbe3e650c8002f8599f($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index a771478f7..2d936b9e7 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef +class ComposerStaticInit3448f0100e342fbe3e650c8002f8599f { public static $files = array ( '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', @@ -385,9 +385,9 @@ class ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitbde5f15deccc7b20dfc55f50254913ef::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit3448f0100e342fbe3e650c8002f8599f::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit3448f0100e342fbe3e650c8002f8599f::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit3448f0100e342fbe3e650c8002f8599f::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 30fa4b70e..23802b991 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -49,18 +49,18 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/wechat-php-sdk.git", - "reference": "acc75f50ac89eacfb66371ffd3e3ecb17073894b" + "reference": "d00deaacb4862bda3525fd246c370fca5c0b6e6e" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/acc75f50ac89eacfb66371ffd3e3ecb17073894b.zip", - "reference": "acc75f50ac89eacfb66371ffd3e3ecb17073894b", + "url": "https://files.phpcomposer.com/files/zoujingli/wechat-php-sdk/d00deaacb4862bda3525fd246c370fca5c0b6e6e.zip", + "reference": "d00deaacb4862bda3525fd246c370fca5c0b6e6e", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "time": "2017-08-22T04:00:09+00:00", + "time": "2017-09-29T04:02:48+00:00", "type": "project", "installation-source": "dist", "autoload": { @@ -174,12 +174,12 @@ "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "45268eeba3da7eedaead09a524e2bc20a0132e29" + "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016" }, "dist": { "type": "zip", - "url": "https://files.phpcomposer.com/files/top-think/framework/45268eeba3da7eedaead09a524e2bc20a0132e29.zip", - "reference": "45268eeba3da7eedaead09a524e2bc20a0132e29", + "url": "https://files.phpcomposer.com/files/top-think/framework/926c9edb0c2682b14f563cac2c8a93f42f729016.zip", + "reference": "926c9edb0c2682b14f563cac2c8a93f42f729016", "shasum": "" }, "require": { @@ -194,7 +194,7 @@ "phpunit/phpunit": "4.8.*", "sebastian/phpcpd": "2.*" }, - "time": "2017-09-07T10:37:47+00:00", + "time": "2017-09-13T03:30:29+00:00", "type": "think-framework", "installation-source": "dist", "autoload": { @@ -381,8 +381,8 @@ }, { "name": "symfony/options-resolver", - "version": "v3.3.8", - "version_normalized": "3.3.8.0", + "version": "v3.3.9", + "version_normalized": "3.3.9.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Common.php b/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Common.php index a8c503c8d..247320f2c 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Common.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Common.php @@ -204,8 +204,8 @@ class Common */ protected function checkRetry($method, $arguments = array()) { + Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", 'ERR'); if (!$this->_retry && in_array($this->errCode, array('40014', '40001', '41001', '42001'))) { - Tools::log("Run {$method} Faild. {$this->errMsg}[{$this->errCode}]", 'ERR'); ($this->_retry = true) && $this->resetAuth(); $this->errCode = 40001; $this->errMsg = 'no access'; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Tools.php b/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Tools.php index 206ccad94..e30065f2c 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Tools.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/Lib/Tools.php @@ -29,8 +29,8 @@ class Tools /** * 产生随机字符串 - * @param int $length - * @param string $str + * @param int $length 指定字符长度 + * @param string $str 字符串前缀 * @return string */ static public function createNoncestr($length = 32, $str = "") @@ -43,19 +43,19 @@ class Tools } /** - * 获取签名 - * @param array $arrdata 签名数组 + * 数据生成签名 + * @param array $data 签名数组 * @param string $method 签名方法 * @return bool|string 签名值 */ - static public function getSignature($arrdata, $method = "sha1") + static public function getSignature($data, $method = "sha1") { if (!function_exists($method)) { return false; } - ksort($arrdata); + ksort($data); $params = array(); - foreach ($arrdata as $key => $value) { + foreach ($data as $key => $value) { $params[] = "{$key}={$value}"; } return $method(join('&', $params)); @@ -144,21 +144,16 @@ class Tools */ static public function httpGet($url) { - $oCurl = curl_init(); - if (stripos($url, "https://") !== false) { - curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); + $curl = curl_init(); + if (stripos($url, "https://") !== 0) { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_SSLVERSION, 1); } - curl_setopt($oCurl, CURLOPT_URL, $url); - curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); - $sContent = curl_exec($oCurl); - $aStatus = curl_getinfo($oCurl); - curl_close($oCurl); - if (intval($aStatus["http_code"]) == 200) { - return $sContent; - } - return false; + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl)); + return (intval($status["http_code"]) === 200) ? $content : false; } /** @@ -169,70 +164,66 @@ class Tools */ static public function httpPost($url, $data) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_POST, true); - if (is_array($data)) { - foreach ($data as &$value) { - if (is_string($value) && stripos($value, '@') === 0 && class_exists('CURLFile', false)) { - $value = new CURLFile(realpath(trim($value, '@'))); - } - } - } - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - $data = curl_exec($ch); - curl_close($ch); - if ($data) { - return $data; - } - return false; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, self::_buildPost($data)); + list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl)); + return (intval($status["http_code"]) === 200) ? $content : false; } /** * 使用证书,以post方式提交xml到对应的接口url * @param string $url POST提交的内容 - * @param array $postdata 请求的地址 + * @param array $data 请求的地址 * @param string $ssl_cer 证书Cer路径 | 证书内容 * @param string $ssl_key 证书Key路径 | 证书内容 * @param int $second 设置请求超时时间 * @return bool|mixed */ - static public function httpsPost($url, $postdata, $ssl_cer = null, $ssl_key = null, $second = 30) + static public function httpsPost($url, $data, $ssl_cer = null, $ssl_key = null, $second = 30) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_TIMEOUT, $second); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_TIMEOUT, $second); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); if (!is_null($ssl_cer) && file_exists($ssl_cer) && is_file($ssl_cer)) { - curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM'); - curl_setopt($ch, CURLOPT_SSLCERT, $ssl_cer); + curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM'); + curl_setopt($curl, CURLOPT_SSLCERT, $ssl_cer); } if (!is_null($ssl_key) && file_exists($ssl_key) && is_file($ssl_key)) { - curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM'); - curl_setopt($ch, CURLOPT_SSLKEY, $ssl_key); + curl_setopt($curl, CURLOPT_SSLKEYTYPE, 'PEM'); + curl_setopt($curl, CURLOPT_SSLKEY, $ssl_key); } - curl_setopt($ch, CURLOPT_POST, true); - if (is_array($postdata)) { - foreach ($postdata as &$data) { - if (is_string($data) && stripos($data, '@') === 0 && class_exists('CURLFile', false)) { - $data = new CURLFile(realpath(trim($data, '@'))); + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, self::_buildPost($data)); + list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl)); + return (intval($status["http_code"]) === 200) ? $content : false; + } + + /** + * POST数据过滤处理 + * @param array $data + * @return array + */ + static private function _buildPost(&$data) + { + if (is_array($data)) { + foreach ($data as &$value) { + if (is_string($value) && $value[0] === '@' && class_exists('CURLFile', false)) { + $filename = realpath(trim($value, '@')); + file_exists($filename) && $value = new CURLFile($filename); } } } - curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); - $result = curl_exec($ch); - curl_close($ch); - if ($result) { - return $result; - } - return false; + return $data; } /** diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCard.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCard.php index dfcae81f9..0a698e39b 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCard.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCard.php @@ -82,9 +82,9 @@ class WechatCard extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::GET_TICKET_URL . "access_token={$this->access_token}" . '&type=wx_card'); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } $expire = $json['expires_in'] ? intval($json['expires_in']) - 100 : 3600; @@ -181,9 +181,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CREATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -205,9 +205,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -231,9 +231,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_DELETE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -257,9 +257,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_USER_GET_LIST . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode']) || empty($json['card_list'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -282,9 +282,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_SEND_HTML . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode']) || empty($json['card_list'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -307,9 +307,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CHECKCODE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode']) || empty($json['card_list'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -331,9 +331,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_GET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -354,9 +354,9 @@ class WechatCard extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CARD_GETCOLORS . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -391,9 +391,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_QRCODE_CREATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -424,9 +424,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_CONSUME . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -453,9 +453,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_DECRYPT . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -487,9 +487,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_GET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -519,9 +519,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_BATCHGET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -547,9 +547,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -574,9 +574,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_CODE_UNAVAILABLE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -597,9 +597,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MODIFY_STOCK . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -620,9 +620,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEETINGCARD_UPDATEUSER . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -643,9 +643,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_ACTIVATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -667,9 +667,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_UPDATEUSER . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -694,9 +694,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_TESTWHILELIST_SET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -721,10 +721,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_LUCKYMONEY_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; - + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -754,9 +753,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_SET_SELFCONSUMECELL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -779,9 +778,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_PAYCELL_SET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -802,9 +801,9 @@ class WechatCard extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CARD_MEMBERCARD_ACTIVATEUSERFORM_SET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php index fc88803e8..b4a375be0 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatCustom.php @@ -48,10 +48,10 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_RECORD . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; - return false; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; + return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; } @@ -71,9 +71,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_KFLIST . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -94,9 +94,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::CUSTOM_SERVICE_GET_ONLINEKFLIST . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -122,9 +122,9 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_CREATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -156,9 +156,9 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_CLOSE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -185,9 +185,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET . "access_token={$this->access_token}" . '&openid=' . $openid); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -220,9 +220,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET_LIST . "access_token={$this->access_token}" . '&kf_account=' . $kf_account); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -242,9 +242,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CUSTOM_SESSION_GET_WAIT . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -269,9 +269,9 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -301,9 +301,9 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -324,9 +324,9 @@ class WechatCustom extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_DEL_URL . "access_token={$this->access_token}" . '&kf_account=' . $account); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -348,9 +348,9 @@ class WechatCustom extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_UPLOAD_HEADIMG_URL . "access_token={$this->access_token}&kf_account={$account}", array('media' => '@' . $imgfile)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php index d1cae9d30..932321ac2 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatDevice.php @@ -54,9 +54,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_APPLYID . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -78,9 +78,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_APPLYSTATUS . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -101,9 +101,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -125,9 +125,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_SEARCH . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -161,12 +161,12 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } - return $json; //这个可以更改为返回true + return $json; } return false; } @@ -187,9 +187,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDLOCATION . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -225,9 +225,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_DEVICE_BINDPAGE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -249,9 +249,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_MATERIAL_ADD . "access_token={$this->access_token}", $data); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -278,9 +278,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_ADD . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -308,9 +308,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -339,9 +339,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_SEARCH . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -364,9 +364,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_PAGE_DELETE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -389,9 +389,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_USER_GETSHAKEINFO . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -427,9 +427,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -454,9 +454,9 @@ class WechatDevice extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SHAKEAROUND_STATISTICS_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php index cd1c55294..f03c15b79 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatExtends.php @@ -88,9 +88,9 @@ class WechatExtends extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::SHORT_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json['short_url']; @@ -122,9 +122,9 @@ class WechatExtends extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::QRCODE_CREATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -166,9 +166,9 @@ class WechatExtends extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::SEMANTIC_API_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -196,9 +196,9 @@ class WechatExtends extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::$DATACUBE_URL_ARR[$type][$subtype] . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return isset($json['list']) ? $json['list'] : $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php index f4a110a90..c01114b91 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatHardware.php @@ -40,9 +40,9 @@ class WechatHardware extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_COMPEL_UNBINDHTTPS . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -60,9 +60,9 @@ class WechatHardware extends Common //dump($result); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -78,9 +78,9 @@ class WechatHardware extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::DEVICE_GETQRCODE . "access_token={$this->access_token}&product_id=$product_id"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -101,9 +101,9 @@ class WechatHardware extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_AUTHORIZE_DEVICE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -122,12 +122,11 @@ class WechatHardware extends Common return false; } $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::DEVICE_CREATE_QRCODE . "access_token={$this->access_token}", Tools::json_encode($data)); - //dump($result); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -148,9 +147,9 @@ class WechatHardware extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::DEVICE_GET_STAT . "access_token={$this->access_token}&device_id=$device_id"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php index 87e8064df..6a84b8e6f 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMedia.php @@ -63,9 +63,9 @@ class WechatMedia extends Common !empty($cache_file) && @unlink($cache_file); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -113,8 +113,6 @@ class WechatMedia extends Common if (!$this->access_token && !$this->getAccessToken()) { return false; } - //原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀 - //如果要获取的素材是视频文件时,不能使用https协议,必须更换成http协议 $url_prefix = $is_video ? str_replace('https', 'http', self::API_URL_PREFIX) : self::API_URL_PREFIX; $url = $url_prefix . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id; $oCurl = curl_init(); @@ -127,13 +125,10 @@ class WechatMedia extends Common curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); - $result = []; - if (intval($aStatus["http_code"]) !== 200) { return false; } - if ($sContent) { if (is_string($sContent)) { $json = json_decode($sContent, true); @@ -170,9 +165,9 @@ class WechatMedia extends Common !empty($cache_file) && @unlink($cache_file); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -205,9 +200,9 @@ class WechatMedia extends Common !empty($cache_file) && @unlink($cache_file); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -229,9 +224,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_NEWS_UPLOAD_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -257,9 +252,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_NEWS_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -282,17 +277,13 @@ class WechatMedia extends Common $data = array('media_id' => $media_id); $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { - if (is_string($result)) { - $json = json_decode($result, true); - if ($json) { - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; - return $this->checkRetry(__FUNCTION__, func_get_args()); - } - return $json; + if (is_string($result) && ($json = json_decode($result, true))) { + if (isset($json['errcode'])) { + $this->errCode = $json['errcode']; + $this->errMsg = $json['errmsg']; + return $this->checkRetry(__FUNCTION__, func_get_args()); } - return $result; + return $json; } return $result; } @@ -313,9 +304,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -345,9 +336,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_BATCHGET_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -374,9 +365,9 @@ class WechatMedia extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::MEDIA_FOREVER_COUNT_URL . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -397,9 +388,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_UPLOADNEWS_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -430,9 +421,9 @@ class WechatMedia extends Common $result = Tools::httpPost(self::UPLOAD_MEDIA_URL . self::MEDIA_VIDEO_UPLOAD . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php index 583a89e23..0e7ab9b18 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMenu.php @@ -54,9 +54,9 @@ class WechatMenu extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::MENU_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -76,9 +76,9 @@ class WechatMenu extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::MENU_GET_URL . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -98,9 +98,9 @@ class WechatMenu extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::MENU_DEL_URL . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -122,9 +122,9 @@ class WechatMenu extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode']) || empty($json['menuid'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json['menuid']; @@ -146,9 +146,9 @@ class WechatMenu extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -170,9 +170,9 @@ class WechatMenu extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::COND_MENU_TRY_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMessage.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMessage.php index b3f5648ee..5ead19de7 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMessage.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatMessage.php @@ -38,9 +38,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/template/get_all_private_template?access_token={$this->access_token}", []); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -60,9 +60,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/template/get_industry?access_token={$this->access_token}", []); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -84,9 +84,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/template/del_private_template?access_token={$this->access_token}", [Tools::json_encode($data)]); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -112,9 +112,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/template/api_set_industry?access_token={$this->access_token}", $json); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errMsg = $json['errmsg']; - $this->errCode = $json['errcode']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -137,9 +137,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/template/api_add_template?access_token={$this->access_token}", $data); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errMsg = $json['errmsg']; - $this->errCode = $json['errcode']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json['template_id']; @@ -184,9 +184,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/template/send?access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errMsg = $json['errmsg']; - $this->errCode = $json['errcode']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -219,9 +219,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/send?access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -254,9 +254,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/sendall?access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -278,9 +278,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/delete?access_token={$this->access_token}", $data); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -311,9 +311,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/preview?access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -339,9 +339,9 @@ class WechatMessage extends Common $result = Tools::httpPost(self::API_URL_PREFIX . "/message/mass/get?access_token={$this->access_token}", $data); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php index 2e7944a4c..cd5200426 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatOauth.php @@ -57,9 +57,9 @@ class WechatOauth extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_TOKEN_URL . "appid={$this->appid}&secret={$this->appsecret}&code={$code}&grant_type=authorization_code"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; Tools::log("WechatOauth::getOauthAccessToken Fail.{$this->errMsg} [{$this->errCode}]", 'ERR'); return false; } @@ -78,9 +78,9 @@ class WechatOauth extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_REFRESH_URL . "appid={$this->appid}&grant_type=refresh_token&refresh_token={$refresh_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; Tools::log("WechatOauth::getOauthRefreshToken Fail.{$this->errMsg} [{$this->errCode}]", 'ERR'); return false; } @@ -101,9 +101,9 @@ class WechatOauth extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_USERINFO_URL . "access_token={$access_token}&openid={$openid}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; Tools::log("WechatOauth::getOauthUserInfo Fail.{$this->errMsg} [{$this->errCode}]", 'ERR'); return false; } @@ -123,12 +123,12 @@ class WechatOauth extends Common $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_AUTH_URL . "access_token={$access_token}&openid={$openid}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; Tools::log("WechatOauth::getOauthAuth Fail.{$this->errMsg} [{$this->errCode}]", 'ERR'); return false; - } else if ($json['errcode'] == 0) { + } elseif (intval($json['errcode']) === 0) { return true; } } diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatPoi.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatPoi.php index 8adf85ad4..7073c9090 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatPoi.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatPoi.php @@ -57,9 +57,9 @@ class WechatPoi extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::POI_ADD . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -82,9 +82,9 @@ class WechatPoi extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::POI_DELETE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -106,9 +106,9 @@ class WechatPoi extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::POI_UPDATE . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return true; @@ -131,9 +131,9 @@ class WechatPoi extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::POI_GET . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -158,9 +158,9 @@ class WechatPoi extends Common $result = Tools::httpPost(self::API_BASE_URL_PREFIX . self::POI_GET_LIST . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -180,9 +180,9 @@ class WechatPoi extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::POI_CATEGORY . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatReceive.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatReceive.php index f2d2300a4..b4d5f0038 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatReceive.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatReceive.php @@ -533,9 +533,9 @@ class WechatReceive extends WechatMessage $result = Tools::httpPost(self::API_URL_PREFIX . "/message/custom/send?access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatScript.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatScript.php index b23df1def..b26dd1f96 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatScript.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatScript.php @@ -82,9 +82,9 @@ class WechatScript extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::GET_TICKET_URL . "access_token={$access_token}" . '&type=jsapi'); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } $this->jsapi_ticket = $json['ticket']; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatService.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatService.php index 778c1d48a..d6c5dc1c6 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatService.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatService.php @@ -366,11 +366,8 @@ class WechatService if (empty($this->component_access_token)) { return false; } - $url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?" - . "appid={$appid}&code={$code}&" - . "grant_type=authorization_code&" - . "component_appid={$this->component_appid}&" - . "component_access_token={$this->component_access_token}"; + $url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid={$appid}&code={$code}&grant_type=authorization_code&" + . "component_appid={$this->component_appid}&component_access_token={$this->component_access_token}"; $json = $this->parseJson(Tools::httpGet($url)); if ($json !== false) { return $json; @@ -386,9 +383,9 @@ class WechatService private function parseJson($result) { $json = json_decode($result, true); - if (!empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return false; } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatUser.php b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatUser.php index 5de7c9f16..03e8f6bb2 100644 --- a/vendor/zoujingli/wechat-php-sdk/Wechat/WechatUser.php +++ b/vendor/zoujingli/wechat-php-sdk/Wechat/WechatUser.php @@ -87,9 +87,9 @@ class WechatUser extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::USER_GET_URL . "access_token={$this->access_token}" . '&next_openid=' . $next_openid); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -111,9 +111,9 @@ class WechatUser extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::USER_INFO_URL . "access_token={$this->access_token}&openid={$openid}"); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -139,9 +139,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::USER_BATCH_INFO_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode']) && !isset($json['user_info_list'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode']) || !isset($json['user_info_list'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json['user_info_list']; @@ -164,9 +164,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::USER_UPDATEREMARK_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -186,9 +186,9 @@ class WechatUser extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::GROUP_GET_URL . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -210,9 +210,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::GROUP_DELETE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -234,13 +234,12 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::USER_GROUP_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode']) || !isset($json['groupid'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); - } else if (isset($json['groupid'])) { - return $json['groupid']; } + return $json['groupid']; } return false; } @@ -259,9 +258,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::GROUP_CREATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -284,9 +283,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::GROUP_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -309,9 +308,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::GROUP_MEMBER_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -334,9 +333,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::GROUP_MEMBER_BATCHUPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -358,9 +357,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_CREATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -383,9 +382,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_UPDATE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -405,9 +404,9 @@ class WechatUser extends Common $result = Tools::httpGet(self::API_URL_PREFIX . self::TAGS_GET_URL . "access_token={$this->access_token}"); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -429,9 +428,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_DELETE_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -454,9 +453,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_GET_USER_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -479,9 +478,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_MEMBER_BATCHTAGGING . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -504,9 +503,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_MEMBER_BATCHUNTAGGING . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -528,9 +527,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::TAGS_LIST . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !isset($json['tagid_list']) || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode']) || !isset($json['tagid_list'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json['tagid_list']; @@ -552,9 +551,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::BACKLIST_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (isset($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -576,9 +575,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::BACKLIST_ADD_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; @@ -600,9 +599,9 @@ class WechatUser extends Common $result = Tools::httpPost(self::API_URL_PREFIX . self::BACKLIST_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data)); if ($result) { $json = json_decode($result, true); - if (!$json || !empty($json['errcode'])) { - $this->errCode = $json['errcode']; - $this->errMsg = $json['errmsg']; + if (empty($json) || !empty($json['errcode'])) { + $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505'; + $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容!'; return $this->checkRetry(__FUNCTION__, func_get_args()); } return $json; diff --git a/vendor/zoujingli/wechat-php-sdk/include.php b/vendor/zoujingli/wechat-php-sdk/include.php index d9c57f330..6057cbe92 100644 --- a/vendor/zoujingli/wechat-php-sdk/include.php +++ b/vendor/zoujingli/wechat-php-sdk/include.php @@ -12,4 +12,6 @@ // | github开源项目:https://github.com/zoujingli/wechat-php-sdk // +---------------------------------------------------------------------- -require __DIR__ . DIRECTORY_SEPARATOR . 'Wechat' . DIRECTORY_SEPARATOR . 'Loader.php'; +if (!class_exists('\Wechat\Loader')) { + require __DIR__ . DIRECTORY_SEPARATOR . 'Wechat' . DIRECTORY_SEPARATOR . 'Loader.php'; +}