add clear
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
<?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']);
|
||||||
|
return $this->request->post($this->_url, ['media' => new \CURLFile($path)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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']);
|
||||||
|
return $this->request->post($this->_msgUrl, ['content' => $content]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace wchat;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ContentAsyncCheck
|
||||||
|
* @package wchat
|
||||||
|
*/
|
||||||
|
class ContentAsyncCheck
|
||||||
|
{
|
||||||
|
private $_ToUserName = '';
|
||||||
|
private $_FromUserName = '';
|
||||||
|
private $_CreateTime = '';
|
||||||
|
private $_MsgType = '';
|
||||||
|
private $_Event = '';
|
||||||
|
private $_isrisky = '';
|
||||||
|
private $_extra_info_json = '';
|
||||||
|
private $_appid = '';
|
||||||
|
private $_trace_id = '';
|
||||||
|
private $_status_code = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getToUserName(): string
|
||||||
|
{
|
||||||
|
return $this->_ToUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFromUserName(): string
|
||||||
|
{
|
||||||
|
return $this->_FromUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCreateTime(): string
|
||||||
|
{
|
||||||
|
return $this->_CreateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMsgType(): string
|
||||||
|
{
|
||||||
|
return $this->_MsgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getEvent(): string
|
||||||
|
{
|
||||||
|
return $this->_Event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIsrisky(): string
|
||||||
|
{
|
||||||
|
return $this->_isrisky;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getExtraInfoJson(): string
|
||||||
|
{
|
||||||
|
return $this->_extra_info_json;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAppid(): string
|
||||||
|
{
|
||||||
|
return $this->_appid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTraceId(): string
|
||||||
|
{
|
||||||
|
return $this->_trace_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getStatusCode(): string
|
||||||
|
{
|
||||||
|
return $this->_status_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $params
|
||||||
|
* @return ContentAsyncCheck|null
|
||||||
|
*/
|
||||||
|
public static function instance(array $params)
|
||||||
|
{
|
||||||
|
static $class = null;
|
||||||
|
if ($class === null) {
|
||||||
|
$class = new ContentAsyncCheck();
|
||||||
|
}
|
||||||
|
return $class->init($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $params
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
private function init($params)
|
||||||
|
{
|
||||||
|
foreach ($params as $item => $param) {
|
||||||
|
$this->{'_' . $item} = $param;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isRisky()
|
||||||
|
{
|
||||||
|
return intval($this->_isrisky) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isSuccess()
|
||||||
|
{
|
||||||
|
return $this->_status_code === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace wchat;
|
||||||
|
|
||||||
|
|
||||||
|
use common\Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SecCheck
|
||||||
|
* @package wchat
|
||||||
|
*/
|
||||||
|
class SecCheck extends SmallProgram
|
||||||
|
{
|
||||||
|
|
||||||
|
private $_url = 'https://api.weixin.qq.com/wxa/img_sec_check?access_token=';
|
||||||
|
|
||||||
|
private $_msgUrl = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=';
|
||||||
|
|
||||||
|
private $_mediaCheckAsync = 'https://api.weixin.qq.com/wxa/media_check_async?access_token=';
|
||||||
|
|
||||||
|
const MEDIA_VIDEO = 1;
|
||||||
|
const MEDIA_IMAGE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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']);
|
||||||
|
return $this->request->post($this->_url, ['media' => new \CURLFile($path)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $url
|
||||||
|
* @param int $type
|
||||||
|
* @return mixed
|
||||||
|
* @throws
|
||||||
|
*/
|
||||||
|
public function mediaAsync(string $url, $type = SecCheck::MEDIA_IMAGE)
|
||||||
|
{
|
||||||
|
if (!in_array($type, [self::MEDIA_IMAGE, self::MEDIA_VIDEO])) {
|
||||||
|
throw new \Exception('暂不支持的文件类型');
|
||||||
|
}
|
||||||
|
$this->request->setHeader(['Content-Type' => 'application/json']);
|
||||||
|
$response = $this->request->post($this->_mediaCheckAsync, [
|
||||||
|
'media_url' => $url,
|
||||||
|
'media_type' => $type
|
||||||
|
]);
|
||||||
|
if (!$response->isResultsOK()) {
|
||||||
|
throw new \Exception($response->getMessage());
|
||||||
|
}
|
||||||
|
return $response->getData('trace_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $params
|
||||||
|
* @return ContentAsyncCheck|null
|
||||||
|
*/
|
||||||
|
public function readByEvent($params)
|
||||||
|
{
|
||||||
|
return ContentAsyncCheck::instance($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $content
|
||||||
|
* @return array|Result|mixed
|
||||||
|
*/
|
||||||
|
public function text($content)
|
||||||
|
{
|
||||||
|
if (empty($content)) {
|
||||||
|
return $this->sendError('文件不存在', 404);
|
||||||
|
}
|
||||||
|
$this->request->setHeader(['Content-Type' => 'application/json']);
|
||||||
|
return $this->request->post($this->_msgUrl, ['content' => $content]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user