diff --git a/qq/SecCheck.php b/qq/SecCheck.php new file mode 100644 index 0000000..ac55e18 --- /dev/null +++ b/qq/SecCheck.php @@ -0,0 +1,50 @@ +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]); + + } + +} diff --git a/wx/ContentAsyncCheck.php b/wx/ContentAsyncCheck.php new file mode 100644 index 0000000..2584599 --- /dev/null +++ b/wx/ContentAsyncCheck.php @@ -0,0 +1,145 @@ +_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; + } + +} diff --git a/wx/SecCheck.php b/wx/SecCheck.php new file mode 100644 index 0000000..af124e5 --- /dev/null +++ b/wx/SecCheck.php @@ -0,0 +1,86 @@ +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]); + } + +}