2019-12-19 15:00:25 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
2020-03-05 12:41:49 +08:00
|
|
|
namespace wchat\qq;
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
|
2020-03-05 12:41:49 +08:00
|
|
|
use wchat\common\Result;
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class SecCheck
|
|
|
|
|
* @package qq
|
|
|
|
|
*/
|
|
|
|
|
class SecCheck extends SmallProgram
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private $_url = 'https://api.q.qq.com/api/json/security/ImgSecCheck?access_token=';
|
|
|
|
|
|
2020-04-03 17:53:17 +08:00
|
|
|
private $_msgUrl = '/api/json/security/MsgSecCheck?access_token=';
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @return array|Result|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function image($path = '')
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists($path)) {
|
|
|
|
|
return $this->sendError('文件不存在', 404);
|
|
|
|
|
}
|
|
|
|
|
$this->request->setUseSwoole(false);
|
2020-04-03 17:49:15 +08:00
|
|
|
$this->request->setHeader('Content-Type', 'multipart/form-data');
|
2020-03-11 16:41:18 +08:00
|
|
|
$this->request->setErrorField('errCode');
|
|
|
|
|
$this->request->setErrorMsgField('errMsg');
|
2020-03-11 16:41:08 +08:00
|
|
|
return $this->request->post($this->_url . $this->config->getAccessToken(), [
|
|
|
|
|
'appid' => $this->config->getAppid(), 'media' => new \CURLFile($path)
|
|
|
|
|
]);
|
2019-12-19 15:00:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $content
|
|
|
|
|
* @return array|Result|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function text($content)
|
|
|
|
|
{
|
|
|
|
|
if (empty($content)) {
|
|
|
|
|
return $this->sendError('文件不存在', 404);
|
|
|
|
|
}
|
2020-04-03 17:48:45 +08:00
|
|
|
$this->request->setUseSwoole(true);
|
2020-03-11 16:38:14 +08:00
|
|
|
$this->request->addHeader('Content-Type', 'application/json');
|
|
|
|
|
$this->request->setErrorField('errCode');
|
|
|
|
|
$this->request->setErrorMsgField('errMsg');
|
2020-05-27 15:51:10 +08:00
|
|
|
$this->request->setData([
|
|
|
|
|
'appid' => $this->config->getAppid(),
|
|
|
|
|
'content' => $content
|
|
|
|
|
]);
|
2020-04-06 02:09:25 +08:00
|
|
|
$this->request->setHost('api.q.qq.com');
|
2020-04-03 17:53:17 +08:00
|
|
|
$this->request->setIsSSL(true);
|
|
|
|
|
|
2020-04-06 02:09:25 +08:00
|
|
|
$url = '/' . ltrim($this->_msgUrl, '/') . $this->config->getAccessToken();
|
2020-05-27 15:51:10 +08:00
|
|
|
return $this->request->post($url);
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|