From 8eb5922d10925142e3a01dd85a43c11f93a11be3 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Mon, 4 Nov 2019 14:39:59 +0800 Subject: [PATCH] add clear --- wx/Miniprogarampage.php | 12 +++++++++--- wx/WxClient.php | 12 ++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/wx/Miniprogarampage.php b/wx/Miniprogarampage.php index 03fb3d2..e882e24 100644 --- a/wx/Miniprogarampage.php +++ b/wx/Miniprogarampage.php @@ -14,7 +14,7 @@ abstract class Miniprogarampage /** @var Config */ protected $config; - /** @var mixed $instance */ + /** @var Miniprogarampage $instance */ protected static $instance = null; /** @var WxClient */ @@ -40,6 +40,12 @@ abstract class Miniprogarampage } static::$instance->config = $config; static::$instance->request->setAgent($config->getAgent()); + + $request = static::$instance->request; + if ($request->getIsSSL()) { + $request->addHeader('ssl_cert_file', $config->getSslCert()); + $request->addHeader('ssl_key_file', $config->getSslKey()); + } return static::$instance; } @@ -57,8 +63,8 @@ abstract class Miniprogarampage $this->request->setMethod(WxClient::GET); $data = $this->request->get('/cgi-bin/token', [ 'grant_type' => 'client_credential', - 'appid' => $this->config->getAppid(), - 'secret' => $this->config->getAppsecret(), + 'appid' => $this->config->getAppid(), + 'secret' => $this->config->getAppsecret(), ]); if (!$data->isResultsOK()) { throw new \Exception($data->getMessage()); diff --git a/wx/WxClient.php b/wx/WxClient.php index 2a30b3f..1422ec1 100644 --- a/wx/WxClient.php +++ b/wx/WxClient.php @@ -100,11 +100,11 @@ class WxClient public function setIsSSL(bool $isSSL) { $this->isSSL = $isSSL; - if ($this->isSSL) { - $ssl = Wx::getMiniProGaRamPage()->getConfig(); - $this->header['ssl_cert_file'] = $ssl->getSslCert(); - $this->header['ssl_key_file'] = $ssl->getSslKey(); - } + } + + public function getIsSSL() + { + return $this->isSSL; } @@ -263,7 +263,7 @@ class WxClient curl_setopt($ch, CURLOPT_SSLKEY, $this->header['ssl_key_file']); } curl_setopt($ch, CURLOPT_NOBODY, FALSE); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);// 超时设置 + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); // 超时设置 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//返回内容 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);// 跟踪重定向 curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');