create(); $client = new Client([ // guzzle http里的配置信息 'base_uri' => $this->base_uri, 'handler' => $stack, 'timeout' => 5, // swoole的配置信息,内容会覆盖guzzle http里的配置信息 'swoole' => [ 'timeout' => 10, 'socket_buffer_size' => 1024 * 1024 * 2, ], ]); return $client->post($uri, [ RequestOptions::JSON => $params, RequestOptions::VERIFY => false, RequestOptions::HEADERS => array_merge( $header, [ 'Content-Type' => 'application/json' ] ), ]); } /** * 返回成功结果 * @param string $message * @param mixed $data * @return bool */ protected function success(string $message = 'success', mixed $data = []): bool { $this->message = $message; $this->data = $data; return true; } /** * 返回失败结果 * @param string $message * @param mixed $data * @return bool */ protected function error(string $message = 'error', mixed $data = []): bool { $this->message = $message; $this->data = $data; return false; } /** * 获取成功数据 * @return mixed */ public function getData(): mixed { return $this->data; } /** * 获取消息 * @return string */ public function getMessage(): string { return $this->message; } }