From 6ce830f9a456d4b21de67a170302d6bb0fd072b8 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 19 Mar 2018 14:10:23 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=A8=A1=E5=BC=8F=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/service/WechatService.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extend/service/WechatService.php b/extend/service/WechatService.php index 40404007c..a24560acf 100644 --- a/extend/service/WechatService.php +++ b/extend/service/WechatService.php @@ -16,6 +16,7 @@ namespace service; use app\wechat\service\FansService; use function Couchbase\defaultDecoder; +use think\Exception; /** * 微信数据服务 @@ -64,13 +65,16 @@ class WechatService 'appsecret' => sysconf('wechat_appsecret'), 'encodingaeskey' => sysconf('wechat_encodingaeskey'), 'mch_id' => sysconf('wechat_mch_id'), - 'partnerkey' => sysconf('wechat_partnerkey'), + 'mch_key' => sysconf('wechat_partnerkey'), 'ssl_cer' => sysconf('wechat_cert_cert'), 'ssl_key' => sysconf('wechat_cert_key'), 'cachepath' => env('cache_path') . 'wechat' . DIRECTORY_SEPARATOR, ]; - $type = '\\WeChat\\' . ucfirst(strtolower($name)); - return new $type($config); + $class = '\\WeChat\\' . ucfirst(strtolower($name)); + if (class_exists($class)) { + return new $class($config); + } + throw new Exception("Class '{$class}' not found"); case 'thr': default: list($appid, $appkey) = [sysconf('wechat_thr_appid'), sysconf('wechat_thr_appkey')];