sendError('文件不存在', 404); } $this->request->setUseSwoole(false); $this->request->setHeader(['Content-Type' => 'multipart/form-data']); $this->request->setErrorField('errCode'); $this->request->setErrorMsgField('errMsg'); return $this->request->post($this->_url . $this->config->getAccessToken(), [ 'appid' => $this->config->getAppid(), 'media' => new \CURLFile($path) ]); } /** * @param $content * @return array|Result|mixed */ public function text($content) { if (empty($content)) { return $this->sendError('文件不存在', 404); } $this->request->setUseSwoole(true); $this->request->addHeader('Content-Type', 'application/json'); $this->request->setErrorField('errCode'); $this->request->setErrorMsgField('errMsg'); $this->request->setData(json_encode([ 'appid' => $this->config->getAppid(), 'content' => $content ])); return $this->request->post($this->_msgUrl . $this->config->getAccessToken()); } }