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


PHP ClientInterface::setBaseUrl方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param \Guzzle\Http\ClientInterface $client     A ClientInterface instance.
  * @param string                       $owner      The owner of the Github repository.
  * @param string                       $repository The Github repository.
  */
 public function __construct(ClientInterface $client, $owner, $repository)
 {
     $this->client = $client;
     $this->owner = $owner;
     $this->repository = $repository;
     $this->client->setBaseUrl('https://api.github.com');
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:14,代码来源:GithubLoader.php

示例2: __construct

 public function __construct(\Guzzle\Http\ClientInterface $client = null)
 {
     if (empty($client)) {
         $client = new \Guzzle\Http\Client();
     }
     $this->client = $client;
     $this->client->setBaseUrl('https://drupal.org/');
 }
开发者ID:pingers,项目名称:drupalreleasedate,代码行数:8,代码来源:DrupalIssueCount.php

示例3: __construct

 /**
  * AmplitudeClient constructor.
  *
  * @param $apiKey
  * @param ClientInterface $client
  */
 public function __construct($apiKey, ClientInterface $client)
 {
     if (empty($apiKey)) {
         throw new \InvalidArgumentException('Empty api key', 500);
     }
     $this->apiKey = $apiKey;
     $this->client = $client;
     $this->client->setBaseUrl(self::AMPLITUDE_URL);
 }
开发者ID:kasl,项目名称:amplitude-php,代码行数:15,代码来源:AmplitudeClient.php

示例4: __construct

 /**
  * @param string $clientId
  * @param string $clientSecret
  * @param string $redirectUri
  * @param array $scopes
  * @param ProviderInterface $provider
  * @param ClientInterface $httpClient
  */
 public function __construct($clientId, $clientSecret, $redirectUri, $scopes = [], ProviderInterface $provider = null, ClientInterface $httpClient = null)
 {
     if (is_null($provider)) {
         $this->provider = new Base(['clientId' => $clientId, 'clientSecret' => $clientSecret, 'redirectUri' => $redirectUri, 'scopes' => $scopes]);
     } else {
         $this->provider = $provider;
     }
     if (is_null($httpClient)) {
         $this->httpClient = new HttpClient();
     } else {
         $this->httpClient = $httpClient;
     }
     $this->httpClient->setBaseUrl(Base::BASE_URL);
 }
开发者ID:quartetcom,项目名称:base-api-php-client,代码行数:22,代码来源:Client.php

示例5: __construct

 /**
  * @param array $configs
  * @param ClientInterface $client
  * @param LoggerInterface $logger
  */
 protected function __construct(array $configs, ClientInterface $client = null, LoggerInterface $logger = null)
 {
     $configs = array_merge($this->getDefaultConfig(), $configs);
     $this->setCredentials($configs);
     $this->setDefaults();
     if ($configs['auth_in_header']) {
         $this->headers['Authorization'] = $this->getAuthHeader();
     }
     $this->logger = $logger ?: new NullLogger();
     $this->client = $client ?: new Client();
     $this->client->setBaseUrl($configs['base_url']);
     $this->client->addSubscriber(new LogPlugin(new PsrLogAdapter($this->logger)));
     $this->tokenRequestPath = $configs['token_request_path'];
 }
开发者ID:careerbuilder,项目名称:php-oauth,代码行数:19,代码来源:Flow.php

示例6: send

 /**
  * @return Response
  * @throws ConnectionErrorException
  * @throws EmptyHostPoolException
  * @throws ServerErrorException
  */
 public function send()
 {
     $exception = null;
     while ($this->hostPool->hasNext()) {
         try {
             $this->guzzleClient->setBaseUrl($this->hostPool->getNext());
             /** @var GuzzleRequest $guzzleRequest */
             $guzzleRequest = $this->guzzleClient->{$this->method}(array($this->url, $this->binds));
             $guzzleRequest->addHeaders($this->headers);
             if ($this->body && $guzzleRequest instanceof EntityEnclosingRequest) {
                 /** @var EntityEnclosingRequest $guzzleRequest */
                 $guzzleRequest->setBody($this->body);
             }
             $this->updateQueryParams($guzzleRequest);
             return new Response($guzzleRequest->send());
         } catch (ClientErrorResponseException $e) {
             return new Response($e->getResponse());
         } catch (ServerErrorResponseException $e) {
             $exception = new ServerErrorException(new Response($e->getResponse()), $e->getMessage(), $e->getCode(), $e);
         } catch (CurlException $e) {
             $exception = new ConnectionErrorException($e->getMessage(), $e->getCode(), $e);
         }
     }
     if ($exception == null) {
         throw new EmptyHostPoolException(sprintf("Empty host pool: %s", $this->hostPool->getName()));
     }
     throw $exception;
 }
开发者ID:allegro,项目名称:toper,代码行数:34,代码来源:Request.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param ClientInterface $httpClient
  * @param array           $options
  * @param LoggerInterface $logger
  */
 public function __construct(ClientInterface $httpClient, array $options, LoggerInterface $logger = null)
 {
     $this->httpClient = $httpClient;
     $scheme = isset($options['scheme']) ? $options['scheme'] : static::DEFAULT_SCHEME;
     $host = isset($options['host']) ? $options['host'] : static::DEFAULT_HOST;
     $port = isset($options['port']) ? $options['port'] : static::DEFAULT_PORT;
     $pathPrefix = isset($options['path_prefix']) ? $options['path_prefix'] : static::DEFAULT_PATH_PREFIX;
     $accessKey = isset($options['access_key']) ? $options['access_key'] : null;
     $secretKey = isset($options['secret_key']) ? $options['secret_key'] : null;
     $this->scheme = $scheme;
     $this->host = $host;
     $this->port = $port;
     $this->pathPrefix = $pathPrefix;
     $this->accessKey = $accessKey;
     $this->secretKey = $secretKey;
     $this->companyName = isset($options['company']) ? $options['company'] : null;
     $this->collectionName = isset($options['collection']) ? $options['collection'] : null;
     $this->options = $options;
     $this->logger = $logger;
     $exceptionFactory = new NamespaceExceptionFactory(new EngineExceptionParser(), 'Sajari\\Engine\\Exception', 'Sajari\\Engine\\Exception\\EngineException');
     $this->httpClient->addSubscriber(new StatusCodeListener());
     $this->httpClient->addSubscriber(new ExceptionListener($exceptionFactory));
     $connectTimeout = 10;
     $timeout = 10;
     if (isset($this->options['curl.options']['CURLOPT_CONNECTTIMEOUT'])) {
         $connectTimeout = (int) $this->options['curl.options']['CURLOPT_CONNECTTIMEOUT'];
     }
     if (isset($this->options['curl.options']['CURLOPT_TIMEOUT'])) {
         $timeout = (int) $this->options['curl.options']['CURLOPT_TIMEOUT'];
     }
     $this->httpClient->setBaseUrl(sprintf('%s://%s', $this->scheme, $this->host));
     $this->httpClient->setConfig(array(HttpClient::SSL_CERT_AUTHORITY => false, HttpClient::CURL_OPTIONS => array(CURLOPT_CONNECTTIMEOUT => $connectTimeout, CURLOPT_TIMEOUT => $timeout)));
 }
开发者ID:benjy,项目名称:sajari-sdk-php,代码行数:40,代码来源:EngineClient.php

示例8: setBaseUrl

 /**
  * Set application hostname, optionally including a base URL, for purge and
  * refresh requests
  *
  * @param string $url Your application’s base URL or hostname
  */
 public function setBaseUrl($url)
 {
     if ($url) {
         $url = $this->filterUrl($url);
     }
     $this->client->setBaseUrl($url);
 }
开发者ID:anhpha,项目名称:reports,代码行数:13,代码来源:AbstractProxyClient.php

示例9: call

 /**
  * Perform a cURL request based on a supplied path
  *
  * @param  string $path
  *
  * @return array
  */
 private function call($path)
 {
     $this->client->setBaseUrl(self::URL);
     $request = $this->client->get($path);
     $request->setHeader('Accept', 'application/json');
     return $request->send()->json();
 }
开发者ID:mikealmond,项目名称:coverartarchive,代码行数:14,代码来源:CoverArt.php

示例10: call

 /**
  * Perform an HTTP request on MusicBrainz
  *
  * @param  string $path
  * @param  array  $params
  * @param  string $options
  * @param  boolean $isAuthRequred
  * @return array
  */
 public function call($path, array $params = array(), array $options = array(), $isAuthRequred = false)
 {
     if ($options['user-agent'] == '') {
         throw new Exception('You must set a valid User Agent before accessing the MusicBrainz API');
     }
     $this->client->setBaseUrl(MbClient::URL);
     $this->client->setConfig(array('data' => $params));
     $request = $this->client->get($path . '{?data*}');
     $request->setHeader('Accept', 'application/json');
     $request->setHeader('User-Agent', $options['user-agent']);
     if ($isAuthRequred) {
         if ($options['user'] != null && $options['password'] != null) {
             $request->setAuth($options['user'], $options['password'], CURLAUTH_DIGEST);
         } else {
             throw new Exception('Authentication is required');
         }
     }
     $request->getQuery()->useUrlEncoding(false);
     return $request->send()->json();
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:29,代码来源:GuzzleMbClient.php

示例11: __construct

 /**
  * HttpClient constructor.
  * @param $clientId
  * @param $apiKey
  * @param $apiSecret
  * @param $endpoint
  * @param ClientInterface $client
  */
 public function __construct($clientId, $apiKey, $apiSecret, $endpoint, ClientInterface $client)
 {
     $this->authData = ['clientId' => $clientId, 'apiKey' => $apiKey, 'sha' => sha1($apiKey . $clientId . $apiSecret)];
     $this->client = $client;
     $this->client->setBaseUrl($endpoint);
 }
开发者ID:hajs86,项目名称:salesmanago,代码行数:14,代码来源:HttpClient.php

示例12: __construct

 /**
  * Constructor.
  *
  * @param \Guzzle\Http\ClientInterface $client A ClientInterface instance.
  */
 public function __construct(ClientInterface $client)
 {
     $this->client = $client;
     $this->client->setBaseUrl('https://api.github.com');
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:10,代码来源:MarkdownGithubHandler.php

示例13: setBaseUrl

 /**
  * {@inheritDoc}
  */
 public function setBaseUrl($url)
 {
     $this->client->setBaseUrl($url);
     return $this;
 }
开发者ID:ferodss,项目名称:salesforce-api,代码行数:8,代码来源:HttpClient.php

示例14: __construct

 /**
  * Constructor.
  *
  * @param \Guzzle\Http\ClientInterface $client A ClientInterface instance.
  * @param string                       $folder The ID of the folder on Google Drive.
  */
 public function __construct(ClientInterface $client, $folder = 'root')
 {
     $this->client = $client;
     $this->folder = $folder;
     $this->client->setBaseUrl('https://www.googleapis.com/upload/drive/v2');
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:12,代码来源:GoogleDriveLoader.php

示例15: setGuzzleClient

 private function setGuzzleClient(GuzzleClientInterface $guzzleClient)
 {
     $guzzleClient->setBaseUrl('https://leanpub.com');
     $this->guzzleClient = $guzzleClient;
 }
开发者ID:matthiasnoback,项目名称:leanpub-api-client,代码行数:5,代码来源:GuzzleClient.php


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