From c4b43deb9f682242ae78988803d4735aad3a7f56 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Fri, 12 Jul 2019 18:51:12 +0800 Subject: [PATCH] add clear --- wx/Account.php | 4 ++-- wx/Base.php | 4 ++-- wx/Recharge.php | 4 ++-- wx/Template.php | 4 ++-- wx/{Http.php => WxClient.php} | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) rename wx/{Http.php => WxClient.php} (96%) diff --git a/wx/Account.php b/wx/Account.php index 0d3698e..3ba7309 100644 --- a/wx/Account.php +++ b/wx/Account.php @@ -15,7 +15,7 @@ class Account extends Base */ public function login($code) { - return Http::get('sns/jscode2session', [ + return WxClient::get('sns/jscode2session', [ 'appid' => $this->appid, 'secret' => $this->appsecret, 'js_code' => $code, @@ -24,4 +24,4 @@ class Account extends Base } -} \ No newline at end of file +} diff --git a/wx/Base.php b/wx/Base.php index dc57842..e801e51 100644 --- a/wx/Base.php +++ b/wx/Base.php @@ -155,7 +155,7 @@ abstract class Base */ public function push($url, $data = [], callable $callback = NULL) { - return Http::post($url, $data, $callback); + return WxClient::post($url, $data, $callback); } /** @@ -246,7 +246,7 @@ abstract class Base */ protected function getAccessToken() { - $data = Http::get('https://api.weixin.qq.com/cgi-bin/token', [ + $data = WxClient::get('https://api.weixin.qq.com/cgi-bin/token', [ 'grant_type' => 'client_credential', 'appid' => $this->appid, 'secret' => $this->appsecret, diff --git a/wx/Recharge.php b/wx/Recharge.php index 62d8235..e4ee54c 100644 --- a/wx/Recharge.php +++ b/wx/Recharge.php @@ -34,7 +34,7 @@ class Recharge extends Base $this->money = $money; $this->orderNo = $orderNo; $this->data['openid'] = $openId; - return Http::post($this->createPayUrl(), $this->builder(), + return WxClient::post($this->createPayUrl(), $this->builder(), function ($result, $body) use ($_this) { $data = $_this->toArray($result); if (isset($data['sign'])) { @@ -120,7 +120,7 @@ class Recharge extends Base $array['sign'] = $this->sign($array); - return Http::post($transfers, static::toXml($array), function ($data) { + return WxClient::post($transfers, static::toXml($array), function ($data) { $array = $this->toArray($data); if ($array['result_code'] != 'SUCCESS') { $data = ['code' => $array['err_code'], 'message' => $array['err_code_des']]; diff --git a/wx/Template.php b/wx/Template.php index 1671f34..dc97fcb 100644 --- a/wx/Template.php +++ b/wx/Template.php @@ -24,7 +24,7 @@ class Template extends Base { $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' . $access; $postBody = json_encode($postBody); - return Http::post($url, $postBody, NULL, ['content-type' => 'application/json']) + return WxClient::post($url, $postBody, NULL, ['content-type' => 'application/json']) ->append('postBody', $postBody); } -} \ No newline at end of file +} diff --git a/wx/Http.php b/wx/WxClient.php similarity index 96% rename from wx/Http.php rename to wx/WxClient.php index f4f395a..504bf77 100644 --- a/wx/Http.php +++ b/wx/WxClient.php @@ -4,7 +4,7 @@ namespace wchat; use Swoole\Coroutine\Http\Client; -class Http +class WxClient { private $url = 'api.weixin.qq.com'; @@ -205,7 +205,7 @@ class Http public static function post($url, $data = [], callable $callback = NULL, array $header = NULL, $isSSl = FALSE) { static $_class = NULL; - if ($_class == NULL) $_class = new Http(); + if ($_class == NULL) $_class = new WxClient(); if (!empty($header)) $_class->setHeaders($header); return $_class->request($url, 'post', $data, $callback, $isSSl); } @@ -223,7 +223,7 @@ class Http public static function put($url, $data = [], callable $callback = NULL, array $header = NULL, $isSSl = FALSE) { static $_class = NULL; - if ($_class == NULL) $_class = new Http(); + if ($_class == NULL) $_class = new WxClient(); if (!empty($header)) $_class->setHeaders($header); return $_class->request($url, 'put', $data, $callback, $isSSl); } @@ -239,7 +239,7 @@ class Http public static function get($url, $data = [], callable $callback = NULL, $header = []) { static $_class = NULL; - if ($_class == NULL) $_class = new Http(); + if ($_class == NULL) $_class = new WxClient(); if (!empty($header)) $_class->setHeaders($header); return $_class->request($url, 'get', $data, $callback); } @@ -254,7 +254,7 @@ class Http public static function option($url, $data = [], $header = []) { static $_class = NULL; - if ($_class == NULL) $_class = new Http(); + if ($_class == NULL) $_class = new WxClient(); if (!empty($header)) $_class->setHeaders($header); return $_class->request($url, 'option', $data); } @@ -269,7 +269,7 @@ class Http public static function delete($url, $data = [], $header = []) { static $_class = NULL; - if ($_class == NULL) $_class = new Http(); + if ($_class == NULL) $_class = new WxClient(); if (!empty($header)) $_class->setHeaders($header); return $_class->request($url, 'delete', $data); }