diff --git a/third_party/phpcommon b/third_party/phpcommon index 21cbf16..2e7067d 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit 21cbf1616cd145c248452eaf77b1e1c7c14c82bd +Subproject commit 2e7067d848c09897f27e6486c38399b27126ca26 diff --git a/webapp/controller/KefuController.class.php b/webapp/controller/KefuController.class.php index ce41a0b..861ed0d 100644 --- a/webapp/controller/KefuController.class.php +++ b/webapp/controller/KefuController.class.php @@ -370,22 +370,6 @@ class KefuController { } } - function httpsRequest($url, $data = null) - { - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $url); - #curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); - if (!empty($data)){ - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - } - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - $output = curl_exec($curl); - curl_close($curl); - return $output; - } - private function getMediaId($gameid) { $type = "image"; @@ -395,10 +379,14 @@ class KefuController { ); $access_token = $this->getAccessToken($gameid); $url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type"; - $res_str = $this->httpsRequest($url, $filedata); - $res = json_decode($res_str, true); - if(isset($res['media_id'])) { - return $res['media_id']; + $response = ''; + if (phpcommon\upload($url, $filedata, $response)) { + $jsonobj = json_decode($response, true); + if(isset($jsonobj['media_id'])) { + return $jsonobj['media_id']; + } else { + return ''; + } } else { return ''; }