當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClientInterface::put方法代碼示例

本文整理匯總了PHP中GuzzleHttp\ClientInterface::put方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClientInterface::put方法的具體用法?PHP ClientInterface::put怎麽用?PHP ClientInterface::put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GuzzleHttp\ClientInterface的用法示例。


在下文中一共展示了ClientInterface::put方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: put

 /**
  * {@inheritdoc}
  */
 public function put($url, array $headers = array(), $content = '')
 {
     $options = array('headers' => $headers, 'body' => $content);
     $request = $this->client->put($url, $options);
     $this->response = $request;
     return $this->response->getBody();
 }
開發者ID:fideloper,項目名稱:DigitalOceanV2,代碼行數:10,代碼來源:Guzzle5Adapter.php

示例2: execute

 /**
  * Execute an operaction
  *
  * A successful operation will return result as an array.
  * An unsuccessful operation will return null.
  *
  * @param  OperationInterface $op
  * @return array|null
  */
 public function execute(OperationInterface $op)
 {
     try {
         if ($op instanceof DeleteOperationInterface) {
             $response = $this->httpClient->delete($op->getEndpoint(), ['headers' => $op->getHeaders()]);
         } elseif ($op instanceof PostOperationInterface) {
             $response = $this->httpClient->post($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } elseif ($op instanceof PatchOperationInterface) {
             $response = $this->httpClient->patch($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } elseif ($op instanceof PutOperationInterface) {
             $response = $this->httpClient->put($op->getEndpoint(), ['headers' => $op->getHeaders(), 'body' => $op->getData()]);
         } else {
             $response = $this->httpClient->get($op->getEndpoint());
         }
     } catch (GuzzleHttp\Exception\ClientException $e) {
         throw new Exception\ClientException('ClientException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
     } catch (GuzzleHttp\Exception\ServerException $e) {
         throw new Exception\ServerException('ServerException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
     }
     $refLink = null;
     $location = null;
     if ($response->hasHeader('ETag')) {
         $refLink = str_replace('"', '', $response->getHeaderLine('ETag'));
     } elseif ($response->hasHeader('Link')) {
         $refLink = str_replace(['<', '>; rel="next"'], ['', ''], $response->getHeaderLine('Link'));
     }
     if ($response->hasHeader('Location')) {
         $location = $response->getHeaderLine('Location');
     }
     $rawValue = $response->getBody(true);
     $value = json_decode($rawValue, true);
     return $op->getObjectFromResponse($refLink, $location, $value, $rawValue);
 }
開發者ID:absynthe,項目名稱:orchestrate-php-client,代碼行數:42,代碼來源:Client.php

示例3: put

 /**
  * {@inheritdoc}
  */
 public function put($url, $content = '')
 {
     $options = [];
     $options['body'] = $content;
     try {
         $this->response = $this->client->put($url, $options);
     } catch (RequestException $e) {
         $this->response = $e->getResponse();
         $this->handleError();
     }
     return $this->response->getBody();
 }
開發者ID:softr,項目名稱:asaas-php-sdk,代碼行數:15,代碼來源:GuzzleHttpAdapter.php

示例4: put

 /**
  * {@inheritDoc}
  */
 public function put(Request $request)
 {
     $response = null;
     try {
         $response = $this->client->put($request->getPath(), array_merge(['body' => $request->getBody()], $this->getConfiguration($request)));
     } catch (RequestException $e) {
         $this->handleRequestException($request, $e);
     }
     return $this->createResponse($response);
 }
開發者ID:gunnartorfis,項目名稱:plex_requests,代碼行數:13,代碼來源:GuzzleAdapter.php

示例5: put

 /**
  * {@inheritdoc}
  */
 public function put($url = null, array $headers = [], $content = null)
 {
     try {
         // http://guzzle.readthedocs.org/en/latest/clients.html#request-options
         $options = array('headers' => $headers, 'body' => $content);
         $response = $this->guzzleClient->put($url, $options);
     } catch (\Exception $e) {
         throw new RequestException($e->getMessage(), $e->getCode(), $e);
     }
     return new Response($response->getStatusCode(), $response->getHeaders(), (string) $response->getBody());
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:14,代碼來源:GuzzleHttpClient.php

示例6: put

 /**
  * {@inheritdoc }
  */
 public function put($url, array $body)
 {
     return $this->httpClient->put($url, ['body' => $body]);
 }
開發者ID:Owsy,項目名稱:sylius-api-php,代碼行數:7,代碼來源:Client.php


注:本文中的GuzzleHttp\ClientInterface::put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。