移除重复代码
This commit is contained in:
parent
e4ea22c051
commit
dd2458c21f
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 21cbf1616cd145c248452eaf77b1e1c7c14c82bd
|
Subproject commit 2e7067d848c09897f27e6486c38399b27126ca26
|
@ -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)
|
private function getMediaId($gameid)
|
||||||
{
|
{
|
||||||
$type = "image";
|
$type = "image";
|
||||||
@ -395,10 +379,14 @@ class KefuController {
|
|||||||
);
|
);
|
||||||
$access_token = $this->getAccessToken($gameid);
|
$access_token = $this->getAccessToken($gameid);
|
||||||
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type";
|
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type";
|
||||||
$res_str = $this->httpsRequest($url, $filedata);
|
$response = '';
|
||||||
$res = json_decode($res_str, true);
|
if (phpcommon\upload($url, $filedata, $response)) {
|
||||||
if(isset($res['media_id'])) {
|
$jsonobj = json_decode($response, true);
|
||||||
return $res['media_id'];
|
if(isset($jsonobj['media_id'])) {
|
||||||
|
return $jsonobj['media_id'];
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user