移除重复代码

This commit is contained in:
aozhiwei 2019-07-29 15:13:20 +08:00
parent e4ea22c051
commit dd2458c21f
2 changed files with 9 additions and 21 deletions

@ -1 +1 @@
Subproject commit 21cbf1616cd145c248452eaf77b1e1c7c14c82bd
Subproject commit 2e7067d848c09897f27e6486c38399b27126ca26

View File

@ -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 '';
}