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


PHP ClientInterface::setDefaultOption方法代碼示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param ClientInterface $client The HTTP client.
  * @param string $accessToken The Strava API access token.
  * @param SportMapperInterface $sportMapper The sport mapper.
  */
 public function __construct(ClientInterface $client, $accessToken, SportMapperInterface $sportMapper)
 {
     $this->httpClient = $client;
     $this->accessToken = $accessToken;
     $this->sportMapper = $sportMapper;
     $this->httpClient->setDefaultOption('headers/Authorization', 'Bearer ' . $this->accessToken);
 }
開發者ID:JavierMartinz,項目名稱:SportTrackerConnector,代碼行數:14,代碼來源:API.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param GuzzleClientInterface $client
  * @param SerializerInterface   $serializer
  * @param string                $apiKey
  */
 public function __construct(GuzzleClientInterface $client, SerializerInterface $serializer, $apiKey)
 {
     $this->apiKey = $apiKey;
     $this->client = $client;
     $this->serializer = $serializer;
     $this->client->setDefaultOption('headers/User-Agent', 'Helthe-Mandrill/' . self::VERSION);
 }
開發者ID:helthe,項目名稱:mandrill,代碼行數:14,代碼來源:Client.php

示例3: prepareClient

 /**
  * @param ClientInterface $client
  * @param string $apiKey
  *
  * @return HTTPClient
  */
 private function prepareClient(ClientInterface $client, $apiKey)
 {
     if ($client->getDefaultOption('timeout') === null) {
         $client->setDefaultOption('timeout', 5.0);
     }
     $client->setDefaultOption('headers/X-Api-Key', $apiKey);
     return $client;
 }
開發者ID:gnoesiboe,項目名稱:FHPostcodeAPIClient,代碼行數:14,代碼來源:Client.php

示例4: __construct

 /**
  * Constructor
  *
  * @param  string                $token   Access Token
  * @param  ClientInterface|null  $client  Client Instance
  */
 public function __construct($token, ClientInterface $client = null)
 {
     if (version_compare(ClientInterface::VERSION, '6') === 1) {
         $this->client = $client ?: new Client(['headers' => ['access_token' => $token]]);
     } else {
         $this->client = $client ?: new Client();
         $this->client->setDefaultOption('headers/access_token', $token);
     }
 }
開發者ID:softr,項目名稱:asaas-php-sdk,代碼行數:15,代碼來源:GuzzleHttpAdapter.php

示例5: __construct

 /**
  * @param string               $token
  * @param ClientInterface|null $client
  */
 public function __construct($token, ClientInterface $client = null)
 {
     if (version_compare(ClientInterface::VERSION, '6') === 1) {
         $this->client = $client ?: new Client(['headers' => ['Authorization' => sprintf('Bearer %s', $token)]]);
     } else {
         $this->client = $client ?: new Client();
         $this->client->setDefaultOption('headers/Authorization', sprintf('Bearer %s', $token));
     }
 }
開發者ID:mix376,項目名稱:DigitalOceanV2,代碼行數:13,代碼來源:GuzzleHttpAdapter.php

示例6: __construct

 /**
  * @param string             $accessToken
  * @param ClientInterface    $client      (optional)
  * @param ExceptionInterface $exception   (optional)
  */
 public function __construct($accessToken, ClientInterface $client = null, ExceptionInterface $exception = null)
 {
     $that = $this;
     $this->client = $client ?: new \GuzzleHttp\Client();
     $this->exception = $exception;
     $this->client->setDefaultOption('headers/Authorization', sprintf('Bearer %s', $accessToken));
     $this->client->getEmitter()->on('complete', function (CompleteEvent $e) use($that) {
         $that->handleResponse($e);
         $e->stopPropagation();
     });
 }
開發者ID:fideloper,項目名稱:DigitalOceanV2,代碼行數:16,代碼來源:Guzzle5Adapter.php

示例7: attachKey

 public function attachKey(ClientInterface $http, $key)
 {
     $subscriber = new SimpleSubscriber(['key' => $key]);
     $http->setDefaultOption('auth', 'simple');
     $http->getEmitter()->attach($subscriber);
     return $http;
 }
開發者ID:knedle,項目名稱:twitter-nette-skeleton,代碼行數:7,代碼來源:Guzzle5AuthHandler.php

示例8: setAuthMethod

 /**
  * Changes the authentication method on all the requests made by this client
  * @param \Snorlax\Auth\Authorization $auth The authorizaztion method
  */
 public function setAuthMethod(Authorization $auth)
 {
     $this->client->setDefaultOption('headers', ['Authorization' => sprintf('%s %s', $auth->getAuthType(), $auth->getCredentials())]);
 }
開發者ID:DennyLoko,項目名稱:snorlax,代碼行數:8,代碼來源:RestClient.php

示例9: __construct

 public function __construct(ClientInterface $client)
 {
     $client->setDefaultOption('headers/Accept', 'application/json');
     $this->http = $client;
 }
開發者ID:arcdigital,項目名稱:hiveage-php,代碼行數:5,代碼來源:Requestor.php

示例10: __construct

 /**
  * Instantiate class with minimal fields to be make valid request
  *
  * @param ClientInterface $client
  */
 public function __construct(ClientInterface $client)
 {
     $this->client = $client;
     $this->client->setDefaultOption('headers/User-Agent', 'caseyw/ziprecruiter-php');
 }
開發者ID:caseyw,項目名稱:ziprecruiter-php,代碼行數:10,代碼來源:ZipRecruiterApi.php

示例11: debug

 /**
  * Prettyprints output and uses ClientInterface debugger
  *
  * @author Eelke van den Bos <eelkevdbos@gmail.com>
  */
 public function debug()
 {
     $this->setOption('prettyprint', 1);
     $this->client->setDefaultOption('debug', true);
 }
開發者ID:eelkevdbos,項目名稱:openexchangerates-php,代碼行數:10,代碼來源:OpenExchangeRates.php


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