当前位置: 首页>>代码示例>>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;未经允许,请勿转载。