当前位置: 首页>>代码示例>>PHP>>正文


PHP ClientInterface::setDefaultOption方法代码示例

本文整理汇总了PHP中Guzzle\Http\ClientInterface::setDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::setDefaultOption方法的具体用法?PHP ClientInterface::setDefaultOption怎么用?PHP ClientInterface::setDefaultOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\ClientInterface的用法示例。


在下文中一共展示了ClientInterface::setDefaultOption方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: enableOAuth2Authentication

 public function enableOAuth2Authentication($clientId, $clientSecret, $accessToken, $refreshToken)
 {
     $this->clientId = $clientId;
     $this->clientSecret = $clientSecret;
     $this->accessToken = $accessToken;
     $this->refreshToken = $refreshToken;
     $this->client->setDefaultOption('request.options/headers/Authorization', 'Bearer ' . $this->accessToken);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:8,代码来源:GoogleDriveLoader.php

示例2: __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 Client();
     $this->exception = $exception;
     $this->client->setDefaultOption('headers/Authorization', sprintf('Bearer %s', $accessToken))->setDefaultOption('events/request.complete', function (Event $event) use($that) {
         $that->handleResponse($event);
         $event->stopPropagation();
     });
 }
开发者ID:fideloper,项目名称:DigitalOceanV2,代码行数:15,代码来源:GuzzleAdapter.php

示例3: enableOauthAuthentication

 public function enableOauthAuthentication($key, $secret, $accessToken = null, $code = null)
 {
     $this->key = $key;
     $this->secret = $secret;
     $this->accessToken = $accessToken;
     $this->code = $code;
     if (!$accessToken && !$code) {
         throw new InvalidArgumentException(sprintf("No OAuth code or access token given, please visit %s to generate a new code", "https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id={$key}"));
     } elseif (!$accessToken && $code) {
         $request = $this->client->post('oauth2/token', array(), array('code' => $this->code, 'grant_type' => 'authorization_code', 'client_id' => $this->key, 'client_secret' => $this->secret));
         try {
             $response = $request->send();
         } catch (ClientErrorResponseException $e) {
             $this->handleBadResponseExceptions($e);
         }
         $token = $response->json();
         $this->accessToken = $token['access_token'];
     }
     $this->client->setDefaultOption('request.options/headers/Authorization', 'Bearer ' . $this->accessToken);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:20,代码来源:DropboxLoader.php

示例4: enableTokenAuthentication

 /**
  * Add the token authentication as default header to the client.
  */
 public function enableTokenAuthentication($token)
 {
     $this->client->setDefaultOption('request.options/headers/Authorization', 'token ' . $token);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:7,代码来源:GithubLoader.php

示例5: __construct

 /**
  * @param string               $token
  * @param ClientInterface|null $client
  */
 public function __construct($token, ClientInterface $client = null)
 {
     $this->client = $client ?: new Client();
     $this->client->setDefaultOption('headers/Authorization', sprintf('Bearer %s', $token));
 }
开发者ID:skaisser,项目名称:upcloud,代码行数:9,代码来源:GuzzleAdapter.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param string               $token  Access Token
  * @param ClientInterface|null $client Client Instance
  */
 public function __construct($token, ClientInterface $client = null)
 {
     $this->client = $client ?: new Client();
     $this->client->setDefaultOption('headers/access_token', $token);
 }
开发者ID:skaisser,项目名称:organizze,代码行数:11,代码来源:GuzzleAdapter.php


注:本文中的Guzzle\Http\ClientInterface::setDefaultOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。