3
This commit is contained in:
+18
-7
@@ -13,11 +13,11 @@ use wchat\common\Result;
|
||||
class SecCheck extends SmallProgram
|
||||
{
|
||||
|
||||
private $_url = 'https://api.weixin.qq.com/wxa/img_sec_check?access_token=';
|
||||
private string $_url = '/wxa/img_sec_check?access_token=';
|
||||
|
||||
private $_msgUrl = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=';
|
||||
private string $_msgUrl = '/wxa/msg_sec_check?access_token=';
|
||||
|
||||
private $_mediaCheckAsync = 'https://api.weixin.qq.com/wxa/media_check_async?access_token=';
|
||||
private string $_mediaCheckAsync = '/wxa/media_check_async?access_token=';
|
||||
|
||||
const MEDIA_VIDEO = 1;
|
||||
const MEDIA_IMAGE = 1;
|
||||
@@ -32,6 +32,8 @@ class SecCheck extends SmallProgram
|
||||
return $this->sendError('文件不存在', 404);
|
||||
}
|
||||
$this->request->setUseSwoole(false);
|
||||
$this->request->setIsSSL(true);
|
||||
$this->request->setHost('api.weixin.qq.com');
|
||||
$this->request->setHeader('Content-Type', 'multipart/form-data');
|
||||
$this->request->setErrorField('errcode');
|
||||
$this->request->setErrorMsgField('errmsg');
|
||||
@@ -50,10 +52,14 @@ class SecCheck extends SmallProgram
|
||||
if (!in_array($type, [self::MEDIA_IMAGE, self::MEDIA_VIDEO])) {
|
||||
throw new \Exception('暂不支持的文件类型');
|
||||
}
|
||||
$this->request->setHeader('Content-Type', 'application/json');
|
||||
$this->request->setIsSSL(true);
|
||||
$this->request->setHost('api.weixin.qq.com');
|
||||
$this->request->setHeader('Content-Type', 'application/json');
|
||||
$this->request->setErrorField('errcode');
|
||||
$this->request->setErrorMsgField('errmsg');
|
||||
$response = $this->request->post($this->_mediaCheckAsync . $this->config->getAccessToken(), [
|
||||
|
||||
$requestUrl = $this->_mediaCheckAsync . $this->config->getAccessToken();
|
||||
$response = $this->request->post($requestUrl, [
|
||||
'media_url' => $url,
|
||||
'media_type' => $type
|
||||
]);
|
||||
@@ -83,10 +89,15 @@ class SecCheck extends SmallProgram
|
||||
if (empty($content)) {
|
||||
return $this->sendError('文件不存在', 404);
|
||||
}
|
||||
$this->request->setHeader('Content-Type', 'application/json');
|
||||
$this->request->setIsSSL(true);
|
||||
$this->request->setHost('api.weixin.qq.com');
|
||||
$this->request->setHeader('Content-Type', 'application/json');
|
||||
$this->request->setErrorField('errcode');
|
||||
$this->request->setErrorMsgField('errmsg');
|
||||
return $this->request->post($this->_msgUrl . $this->config->getAccessToken(), ['content' => $content]);
|
||||
|
||||
$requestUrl = $this->_msgUrl . $this->config->getAccessToken();
|
||||
|
||||
return $this->request->post($requestUrl, ['content' => $content]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user