baseUri = env('SHOP_URL'); $this->key = env('SHOP_KEY'); } public function request($method, $action, $data = []) { $client = new Client(); $url = $this->baseUri . $action; $param = [ 'headers' => [ 'Key' => $this->key ], 'query' => $data ]; $resp = $client->request($method, $url, $param); if ($resp->getStatusCode() != 200) { throw new Exception('shop service error'); } return json_decode($resp->getBody()->getContents(), true); } }