app_key = $appKey; return $this; } /** * 自定义接口 * @param string $method * @return $this */ public function setMethod($method = ''): self { $this->method = $method; return $this; } /** * 请求参数 * @param array $param * @return $this */ public function param(array $param): self { $this->param = $param; return $this; } /** * 获取配置信息 * @return $this */ private function getConfig(): self { $this->app_key = config('dtapp.dingdanxia.app_key'); return $this; } /** * 返回Array * @return array|mixed * @throws DtaException */ public function toArray() { //首先检测是否支持curl if (!extension_loaded("curl")) { throw new HttpException(404, '请开启curl模块!'); } if (empty($this->app_key)) { $this->getConfig(); } if (empty($this->method)) { throw new DtaException('请检查接口'); } $this->output = HttpService::instance() ->url($this->method) ->data($this->param) ->post() ->toArray(); return $this->output; } }