sendError('文件不存在', 404); } $access_token = $this->payConfig->getAccessToken(); return $this->upload($this->_url . '?access_token=' . $access_token, [ 'media' => new \CURLFile($path) ]); } /** * @param string $url * @param int $type * @return mixed * @throws */ public function mediaAsync(string $url, int $type = SecCheck::MEDIA_IMAGE): Result { if (!in_array($type, [self::MEDIA_IMAGE, self::MEDIA_VIDEO])) { throw new \Exception('暂不支持的文件类型'); } $requestUrl = $this->_mediaCheckAsync . $this->payConfig->getAccessToken(); return $this->post($requestUrl, ['media_url' => $url, 'media_type' => $type]); } /** * @param $params * @return ContentAsyncCheck|null */ public function readByEvent($params): ?ContentAsyncCheck { return ContentAsyncCheck::instance($params); } /** * @param $content * @return Result */ public function text($content): Result { if (empty($content)) { return $this->sendError('文件不存在', 404); } $requestUrl = $this->_msgUrl . $this->payConfig->getAccessToken(); return $this->post($requestUrl, ['content' => $content]); } }