コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function xml()
 {
     try {
         $result = $this->response->xml();
     } catch (\Exception $exception) {
         throw GuzzleRestException::createFromException($exception);
     }
     return $result;
 }
コード例 #2
0
ファイル: GuzzleRestClient.php プロジェクト: Maksold/platform
 /**
  * Performed request and return response
  *
  * @param string $method
  * @param string $url
  * @param array $params
  * @param mixed $data
  * @param array $headers
  * @param array $options
  * @return string
  * @throws GuzzleRestException
  */
 public function performRequest($method, $url, array $params = [], $data = null, array $headers = [], array $options = [])
 {
     $url = $this->buildUrl($url, $params);
     $options = array_merge($this->defaultOptions, $options);
     if (is_array($data) && (!isset($headers['Content-Type']) || $headers['Content-Type'] == 'application/json')) {
         $headers['Content-Type'] = 'application/json';
         $data = json_encode($data);
     }
     try {
         $this->lastGuzzleRequest = $request = $this->getGuzzleClient()->createRequest($method, $url, $headers, $data, $options);
         $response = $request->send();
     } catch (\Exception $exception) {
         throw GuzzleRestException::createFromException($exception);
     }
     $this->lastResponse = new GuzzleRestResponse($response, (string) $request->getUrl());
     return $this->lastResponse;
 }