[更新]ComposerUpdate

This commit is contained in:
Anyon 2018-05-23 16:15:58 +08:00
parent cd53224075
commit e2397096a8
5 changed files with 83 additions and 87 deletions

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291::getLoader(); return ComposerAutoloaderInitde40dbadcc666977486255074dc624e9::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291 class ComposerAutoloaderInitde40dbadcc666977486255074dc624e9
{ {
private static $loader; private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInitde40dbadcc666977486255074dc624e9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitde40dbadcc666977486255074dc624e9', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf87766a7411e551cf24d607cb3736291::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInitde40dbadcc666977486255074dc624e9::getInitializer($loader));
} else { } else {
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -48,19 +48,19 @@ class ComposerAutoloaderInitf87766a7411e551cf24d607cb3736291
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitf87766a7411e551cf24d607cb3736291::$files; $includeFiles = Composer\Autoload\ComposerStaticInitde40dbadcc666977486255074dc624e9::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref87766a7411e551cf24d607cb3736291($fileIdentifier, $file); composerRequirede40dbadcc666977486255074dc624e9($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequiref87766a7411e551cf24d607cb3736291($fileIdentifier, $file) function composerRequirede40dbadcc666977486255074dc624e9($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInitf87766a7411e551cf24d607cb3736291 class ComposerStaticInitde40dbadcc666977486255074dc624e9
{ {
public static $files = array ( public static $files = array (
'1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
@ -287,9 +287,9 @@ class ComposerStaticInitf87766a7411e551cf24d607cb3736291
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInitde40dbadcc666977486255074dc624e9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInitde40dbadcc666977486255074dc624e9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf87766a7411e551cf24d607cb3736291::$classMap; $loader->classMap = ComposerStaticInitde40dbadcc666977486255074dc624e9::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -133,12 +133,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/WeOpenDeveloper.git", "url": "https://github.com/zoujingli/WeOpenDeveloper.git",
"reference": "a6739da337a0c0b6e2da8103b353a42044b4a0c7" "reference": "21273dc11c4fb3de4ab07d74a696bf0e4661cea3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/a6739da337a0c0b6e2da8103b353a42044b4a0c7.zip", "url": "https://files.phpcomposer.com/files/zoujingli/WeOpenDeveloper/21273dc11c4fb3de4ab07d74a696bf0e4661cea3.zip",
"reference": "a6739da337a0c0b6e2da8103b353a42044b4a0c7", "reference": "21273dc11c4fb3de4ab07d74a696bf0e4661cea3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -147,7 +147,7 @@
"php": ">=5.4", "php": ">=5.4",
"zoujingli/wechat-developer": "^1.0" "zoujingli/wechat-developer": "^1.0"
}, },
"time": "2018-05-12T14:10:32+00:00", "time": "2018-05-23T07:08:07+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -272,8 +272,8 @@
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
"version": "v3.4.9", "version": "v3.4.10",
"version_normalized": "3.4.9.0", "version_normalized": "3.4.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/options-resolver.git", "url": "https://github.com/symfony/options-resolver.git",

View File

@ -88,8 +88,8 @@ class Service
public function getComponentAccessToken() public function getComponentAccessToken()
{ {
$cache = 'wechat_component_access_token'; $cache = 'wechat_component_access_token';
if (($component_access_token = Tools::getCache($cache))) { if (($componentAccessToken = Tools::getCache($cache))) {
return $component_access_token; return $componentAccessToken;
} }
$data = [ $data = [
'component_appid' => $this->config->get('component_appid'), 'component_appid' => $this->config->get('component_appid'),
@ -107,17 +107,17 @@ class Service
/** /**
* 获取授权方的帐号基本信息 * 获取授权方的帐号基本信息
* @param string $authorizer_appid 授权公众号或小程序的appid * @param string $authorizerAppid 授权公众号或小程序的appid
* @return array * @return array
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function getAuthorizerInfo($authorizer_appid) public function getAuthorizerInfo($authorizerAppid)
{ {
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token={$componentAccessToken}";
$data = [ $data = [
'authorizer_appid' => $authorizer_appid, 'authorizer_appid' => $authorizerAppid,
'component_appid' => $this->config->get('component_appid'), 'component_appid' => $this->config->get('component_appid'),
]; ];
$result = $this->httpPostForJson($url, $data); $result = $this->httpPostForJson($url, $data);
@ -129,21 +129,21 @@ class Service
/** /**
* 设置授权方的选项信息 * 设置授权方的选项信息
* @param string $authorizer_appid 授权公众号或小程序的appid * @param string $authorizerAppid 授权公众号或小程序的appid
* @param string $option_name 选项名称 * @param string $optionName 选项名称
* @param string $option_value 设置的选项值 * @param string $optionValue 设置的选项值
* @return array * @return array
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function setAuthorizerOption($authorizer_appid, $option_name, $option_value) public function setAuthorizerOption($authorizerAppid, $optionName, $optionValue)
{ {
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/ api_set_authorizer_option?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_set_authorizer_option?component_access_token={$componentAccessToken}";
$result = $this->httpPostForJson($url, [ $result = $this->httpPostForJson($url, [
'option_name' => $option_name, 'option_name' => $optionName,
'option_value' => $option_value, 'option_value' => $optionValue,
'authorizer_appid' => $authorizer_appid, 'authorizer_appid' => $authorizerAppid,
'component_appid' => $this->config->get('component_appid'), 'component_appid' => $this->config->get('component_appid'),
]); ]);
return $result; return $result;
@ -157,8 +157,8 @@ class Service
*/ */
public function getPreauthCode() public function getPreauthCode()
{ {
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token={$componentAccessToken}";
$result = $this->httpPostForJson($url, ['component_appid' => $this->config->get('component_appid')]); $result = $this->httpPostForJson($url, ['component_appid' => $this->config->get('component_appid')]);
if (empty($result['pre_auth_code'])) { if (empty($result['pre_auth_code'])) {
throw new InvalidResponseException('GetPreauthCode Faild.', '0', $result); throw new InvalidResponseException('GetPreauthCode Faild.', '0', $result);
@ -168,67 +168,67 @@ class Service
/** /**
* 获取授权回跳地址 * 获取授权回跳地址
* @param string $redirect_uri 回调URI * @param string $redirectUri 回调URI
* @param integer $auth_type 要授权的帐号类型 * @param integer $authType 要授权的帐号类型
* @return bool * @return bool
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function getAuthRedirect($redirect_uri, $auth_type = 3) public function getAuthRedirect($redirectUri, $authType = 3)
{ {
$redirect_uri = urlencode($redirect_uri); $redirectUri = urlencode($redirectUri);
$pre_auth_code = $this->getPreauthCode(); $preAuthCode = $this->getPreauthCode();
$component_appid = $this->config->get('component_appid'); $componentAppid = $this->config->get('component_appid');
return "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$component_appid}&pre_auth_code={$pre_auth_code}&redirect_uri={$redirect_uri}&auth_type={$auth_type}"; return "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$componentAppid}&pre_auth_code={$preAuthCode}&redirect_uri={$redirectUri}&auth_type={$authType}";
} }
/** /**
* 使用授权码换取公众号或小程序的接口调用凭据和授权信息 * 使用授权码换取公众号或小程序的接口调用凭据和授权信息
* @param null $auth_code 授权码 * @param null $authCode 授权码
* @return bool|array * @return bool|array
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function getQueryAuthorizerInfo($auth_code = null) public function getQueryAuthorizerInfo($authCode = null)
{ {
if (is_null($auth_code) && isset($_GET['auth_code'])) { if (is_null($authCode) && isset($_GET['auth_code'])) {
$auth_code = $_GET['auth_code']; $authCode = $_GET['auth_code'];
} }
if (empty($auth_code)) { if (empty($authCode)) {
return false; return false;
} }
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token={$componentAccessToken}";
$data = [ $data = [
'authorization_code' => $authCode,
'component_appid' => $this->config->get('component_appid'), 'component_appid' => $this->config->get('component_appid'),
'authorization_code' => $auth_code,
]; ];
$result = $this->httpPostForJson($url, $data); $result = $this->httpPostForJson($url, $data);
if (empty($result['authorization_info'])) { if (empty($result['authorization_info'])) {
throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data);
} }
$authorizer_appid = $result['authorization_info']['authorizer_appid']; $authorizerAppid = $result['authorization_info']['authorizer_appid'];
$authorizer_access_token = $result['authorization_info']['authorizer_access_token']; $authorizerAccessToken = $result['authorization_info']['authorizer_access_token'];
// 缓存授权公众号访问 ACCESS_TOKEN // 缓存授权公众号访问 ACCESS_TOKEN
Tools::setCache("{$authorizer_appid}_access_token", $authorizer_access_token, 7000); Tools::setCache("{$authorizerAppid}_access_token", $authorizerAccessToken, 7000);
return $result['authorization_info']; return $result['authorization_info'];
} }
/** /**
* 获取(刷新)授权公众号的令牌 * 获取(刷新)授权公众号的令牌
* @param string $authorizer_appid 授权公众号或小程序的appid * @param string $authorizerAppid 授权公众号或小程序的appid
* @param string $authorizer_refresh_token 授权方的刷新令牌 * @param string $authorizerRefreshToken 授权方的刷新令牌
* @return array * @return array
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function refreshAccessToken($authorizer_appid, $authorizer_refresh_token) public function refreshAccessToken($authorizerAppid, $authorizerRefreshToken)
{ {
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token={$componentAccessToken}";
$data = [ $data = [
'authorizer_appid' => $authorizer_appid, 'authorizer_appid' => $authorizerAppid,
'authorizer_refresh_token' => $authorizer_refresh_token, 'authorizer_refresh_token' => $authorizerRefreshToken,
'component_appid' => $this->config->get('component_appid'), 'component_appid' => $this->config->get('component_appid'),
]; ];
$result = $this->httpPostForJson($url, $data); $result = $this->httpPostForJson($url, $data);
@ -236,39 +236,39 @@ class Service
throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data);
} }
// 缓存授权公众号访问 ACCESS_TOKEN // 缓存授权公众号访问 ACCESS_TOKEN
Tools::setCache("{$authorizer_appid}_access_token", $result['authorizer_access_token'], 7000); Tools::setCache("{$authorizerAppid}_access_token", $result['authorizer_access_token'], 7000);
return $result; return $result;
} }
/** /**
* oauth 授权跳转接口 * oauth 授权跳转接口
* @param string $authorizer_appid 授权公众号或小程序的appid * @param string $authorizerAppid 授权公众号或小程序的appid
* @param string $redirect_uri 回调地址 * @param string $redirectUri 回调地址
* @param string $scope snsapi_userinfo|snsapi_base * @param string $scope snsapi_userinfo|snsapi_base
* @return string * @return string
*/ */
public function getOauthRedirect($authorizer_appid, $redirect_uri, $scope = 'snsapi_userinfo') public function getOauthRedirect($authorizerAppid, $redirectUri, $scope = 'snsapi_userinfo')
{ {
$redirect_url = urlencode($redirect_uri); $redirectUri = urlencode($redirectUri);
$component_appid = $this->config->get('component_appid'); $componentAppid = $this->config->get('component_appid');
return "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$authorizer_appid}&redirect_uri={$redirect_url}&response_type=code&scope={$scope}&state={$authorizer_appid}&component_appid={$component_appid}#wechat_redirect"; return "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$authorizerAppid}&redirect_uri={$redirectUri}&response_type=code&scope={$scope}&state={$authorizerAppid}&component_appid={$componentAppid}#wechat_redirect";
} }
/** /**
* 通过code获取AccessToken * 通过code获取AccessToken
* @param string $authorizer_appid 授权公众号或小程序的appid * @param string $authorizerAppid 授权公众号或小程序的appid
* @return bool|array * @return bool|array
* @throws InvalidResponseException * @throws InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException * @throws \WeChat\Exceptions\LocalCacheException
*/ */
public function getOauthAccessToken($authorizer_appid) public function getOauthAccessToken($authorizerAppid)
{ {
if (empty($_GET['code'])) { if (empty($_GET['code'])) {
return false; return false;
} }
$component_appid = $this->config->get('component_appid'); $componentAppid = $this->config->get('component_appid');
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid={$authorizer_appid}&code={$_GET['code']}&grant_type=authorization_code&component_appid={$component_appid}&component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid={$authorizerAppid}&code={$_GET['code']}&grant_type=authorization_code&component_appid={$componentAppid}&component_access_token={$componentAccessToken}";
return $this->httpGetForJson($url); return $this->httpGetForJson($url);
} }
@ -282,38 +282,34 @@ class Service
*/ */
public function getAuthorizerList($count = 500, $offset = 0) public function getAuthorizerList($count = 500, $offset = 0)
{ {
$component_appid = $this->config->get('component_appid'); $componentAppid = $this->config->get('component_appid');
$component_access_token = $this->getComponentAccessToken(); $componentAccessToken = $this->getComponentAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_list?component_access_token={$component_access_token}"; $url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_list?component_access_token={$componentAccessToken}";
return $this->httpPostForJson($url, [ return $this->httpPostForJson($url, ['count' => $count, 'offset' => $offset, 'component_appid' => $componentAppid]);
'count' => $count,
'offset' => $offset,
'component_appid' => $component_appid,
]);
} }
/** /**
* 创建指定授权公众号接口实例 * 创建指定授权公众号接口实例
* @param string $name 需要加载的接口实例名称 * @param string $name 需要加载的接口实例名称
* @param string $authorizer_appid 授权公众号的appid * @param string $authorizerAppid 授权公众号的appid
* @param string $type 加载SDK类型 WeChat|WeMini * @param string $type 加载SDK类型 WeChat|WeMini
* @return \WeChat\Card|\WeChat\Custom|\WeChat\Media|\WeChat\Menu|\WeChat\Oauth|\WeChat\Pay|\WeChat\Product|\WeChat\Qrcode|\WeChat\Receive|\WeChat\Scan|\WeChat\Script|\WeChat\Shake|\WeChat\Tags|\WeChat\Template|\WeChat\User|\WeChat\Wifi * @return \WeChat\Card|\WeChat\Custom|\WeChat\Media|\WeChat\Menu|\WeChat\Oauth|\WeChat\Pay|\WeChat\Product|\WeChat\Qrcode|\WeChat\Receive|\WeChat\Scan|\WeChat\Script|\WeChat\Shake|\WeChat\Tags|\WeChat\Template|\WeChat\User|\WeChat\Wifi
*/ */
public function instance($name, $authorizer_appid, $type = 'WeChat') public function instance($name, $authorizerAppid, $type = 'WeChat')
{ {
$className = "{$type}\\" . ucfirst(strtolower($name)); $className = "{$type}\\" . ucfirst(strtolower($name));
return new $className($this->getConfig($authorizer_appid)); return new $className($this->getConfig($authorizerAppid));
} }
/** /**
* 获取授权公众号配置参数 * 获取授权公众号配置参数
* @param string $authorizer_appid 授权公众号的appid * @param string $authorizerAppid 授权公众号的appid
* @return array * @return array
*/ */
public function getConfig($authorizer_appid) public function getConfig($authorizerAppid)
{ {
$config = $this->config->get(); $config = $this->config->get();
$config['appid'] = $authorizer_appid; $config['appid'] = $authorizerAppid;
$config['token'] = $this->config->get('component_token'); $config['token'] = $this->config->get('component_token');
$config['appsecret'] = $this->config->get('component_appsecret'); $config['appsecret'] = $this->config->get('component_appsecret');
$config['encodingaeskey'] = $this->config->get('component_encodingaeskey'); $config['encodingaeskey'] = $this->config->get('component_encodingaeskey');