當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。