2019-12-19 15:00:25 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace qq;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use common\Result;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class SecCheck
|
|
|
|
|
* @package qq
|
|
|
|
|
*/
|
|
|
|
|
class SecCheck extends SmallProgram
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private $_url = 'https://api.q.qq.com/api/json/security/ImgSecCheck?access_token=';
|
|
|
|
|
|
|
|
|
|
private $_msgUrl = 'https://api.q.qq.com/api/json/security/MsgSecCheck?access_token=';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @return array|Result|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function image($path = '')
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists($path)) {
|
|
|
|
|
return $this->sendError('文件不存在', 404);
|
|
|
|
|
}
|
|
|
|
|
$this->request->setUseSwoole(false);
|
|
|
|
|
$this->request->setHeader(['Content-Type' => 'multipart/form-data']);
|
2020-01-03 14:50:07 +08:00
|
|
|
return $this->request->post($this->_url . $this->config->getAccessToken(), ['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);
|
|
|
|
|
}
|
|
|
|
|
$this->request->setUseSwoole(false);
|
|
|
|
|
$this->request->setHeader(['Content-Type' => 'application/json']);
|
2020-01-03 14:50:07 +08:00
|
|
|
return $this->request->post($this->_msgUrl . $this->config->getAccessToken(), ['content' => $content]);
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|