Files
kiri-wchat/qq/SecCheck.php
T

57 lines
1.3 KiB
PHP
Raw Normal View History

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
2022-09-09 16:42:55 +08:00
use Kiri\Client;
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()
];
return $this->upload($path, $data);
}
/**
* @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 01:08:06 +08:00
$url = '/' . ltrim($this->_url, '/') . $this->payConfig->getAccessToken();
2019-12-19 15:00:25 +08:00
2023-11-14 01:08:06 +08:00
return $this->post($url, ['appid' => $this->payConfig->appId, 'content' => $content]);
}
2019-12-19 15:00:25 +08:00
}