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
|
|
|
|
|
{
|
|
|
|
|
|
2023-11-14 01:08:06 +08:00
|
|
|
private string $_url = '/api/json/security/ImgSecCheck?access_token=';
|
|
|
|
|
|
|
|
|
|
private string $_msgUrl = '/api/json/security/MsgSecCheck?access_token=';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @return Result
|
|
|
|
|
*/
|
|
|
|
|
public function image(string $path = ''): Result
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists($path)) {
|
|
|
|
|
return $this->sendError('文件不存在', 404);
|
2023-11-07 15:13:11 +08:00
|
|
|
}
|
2020-04-03 17:53:17 +08:00
|
|
|
|
2023-11-14 01:08:06 +08:00
|
|
|
$real_path = new \CURLFile($path);
|
|
|
|
|
$data = [
|
|
|
|
|
'appid' => $this->payConfig->appId,
|
|
|
|
|
'media' => $real_path,
|
|
|
|
|
'form-data[filename]' => $path,
|
|
|
|
|
'form-data[content-type]' => $real_path->getMimeType()
|
|
|
|
|
];
|
2023-11-14 12:39:28 +08:00
|
|
|
return $this->upload('api.q.qq.com', $this->_url, $data);
|
2023-11-14 01:08:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $content
|
|
|
|
|
* @return Result
|
|
|
|
|
*/
|
|
|
|
|
public function text(string $content): Result
|
|
|
|
|
{
|
|
|
|
|
if (empty($content)) {
|
|
|
|
|
return $this->sendError('文件不存在', 404);
|
2023-11-07 15:13:11 +08:00
|
|
|
}
|
2023-11-14 12:39:28 +08:00
|
|
|
$url = '/' . ltrim($this->_msgUrl, '/') . $this->payConfig->getAccessToken();
|
2019-12-19 15:00:25 +08:00
|
|
|
|
2023-11-14 12:39:28 +08:00
|
|
|
return $this->post('api.q.qq.com', $url, ['appid' => $this->payConfig->appId, 'content' => $content]);
|
2023-11-14 01:08:06 +08:00
|
|
|
}
|
2019-12-19 15:00:25 +08:00
|
|
|
|
|
|
|
|
}
|