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


PHP Client::getDefaultUserAgent方法代码示例

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


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

示例1: __construct

 public function __construct(Config $config)
 {
     $defaultOptions = ['scheme' => 'http'];
     $requiredOptions = ['hostname'];
     $options = ['hostname' => $config->getHostname(), 'scheme' => $config->getUseSsl() ? 'https' : 'http', 'port' => $config->getPort()];
     $options = Collection::fromConfig($options, $defaultOptions, $requiredOptions);
     $this->client = new Client(['base_url' => ['{scheme}://{hostname}:{port}/api/', $options->toArray()], 'defaults' => ['auth' => [$config->getLogin(), $config->getPassword()], 'expect' => false, 'headers' => ['Accept' => 'application/json', 'User-Agent' => 'Openl10n ' . Client::getDefaultUserAgent()]]]);
     $this->registerDefaultEntryPoints();
 }
开发者ID:bein-sports,项目名称:openl10n-sdk,代码行数:9,代码来源:Api.php

示例2: loadBaseClient

 /**
  * Set adapter and create Guzzle base client.
  *
  * @return \GuzzleHttp\Client
  */
 private function loadBaseClient(array $settings = [])
 {
     // Force the authorization scheme to 'tevoauth'
     $settings['defaults']['auth'] = 'tevoauth';
     if ($this->_baseClientAdapter) {
         $settings['adapter'] = $this->_baseClientAdapter;
     }
     $this->_baseClient = new BaseClient($settings);
     // Attach the TEvoAuth subscriber to handle the required authorization
     $this->_baseClient->getEmitter()->attach(new TEvoAuth($this->_settings['apiToken'], $this->_settings['apiSecret']));
     // Don't need these any more
     unset($this->_settings['apiToken'], $this->_settings['apiSecret']);
     // Set a custom User Agent indicating which version of this library we are using.
     // Can’t set this in $settings['defaults'] above because we want to prepend the default.
     $this->_baseClient->setDefaultOption('headers/User-Agent', 'ticketevolution-php/' . self::VERSION . ' ' . $this->_baseClient->getDefaultUserAgent());
     return $this->_baseClient;
 }
开发者ID:sonnygauran,项目名称:ticketevolution-php,代码行数:22,代码来源:Client.php

示例3: testAddsDefaultUserAgentHeaderWithoutDefaultOptions

 public function testAddsDefaultUserAgentHeaderWithoutDefaultOptions()
 {
     $client = new Client();
     $this->assertEquals(['User-Agent' => Client::getDefaultUserAgent()], $client->getDefaultOption('headers'));
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:5,代码来源:ClientTest.php

示例4: createGuzzleRequest

 private function createGuzzleRequest(Psr7Request $psrRequest, array $options)
 {
     $ringConfig = [];
     // Remove unsupported options.
     foreach (array_keys($options) as $key) {
         if (!isset(self::$validOptions[$key])) {
             unset($options[$key]);
         }
     }
     // Handle delay option.
     if (isset($options['delay'])) {
         $ringConfig['delay'] = $options['delay'];
         unset($options['delay']);
     }
     // Prepare sink option.
     if (isset($options['sink'])) {
         $ringConfig['save_to'] = $options['sink'] instanceof Psr7StreamInterface ? new GuzzleStream($options['sink']) : $options['sink'];
         unset($options['sink']);
     }
     // Ensure that all requests are async and lazy like Guzzle 6.
     $options['future'] = 'lazy';
     // Create the Guzzle 5 request from the provided PSR7 request.
     $request = $this->client->createRequest($psrRequest->getMethod(), $psrRequest->getUri(), $options);
     // For the request body, adapt the PSR stream to a Guzzle stream.
     $body = $psrRequest->getBody();
     if ($body->getSize() === 0) {
         $request->setBody(null);
     } else {
         $request->setBody(new GuzzleStream($body));
     }
     $request->setHeaders($psrRequest->getHeaders());
     $request->setHeader('User-Agent', 'aws-sdk-php/' . Sdk::VERSION . ' ' . Client::getDefaultUserAgent());
     // Make sure the delay is configured, if provided.
     if ($ringConfig) {
         foreach ($ringConfig as $k => $v) {
             $request->getConfig()->set($k, $v);
         }
     }
     return $request;
 }
开发者ID:Cinemacloud,项目名称:angular-moviemasher,代码行数:40,代码来源:GuzzleHandler.php

示例5: createGuzzleRequest

 private function createGuzzleRequest(Psr7Request $psrRequest, array $options)
 {
     $ringConfig = [];
     $statsCallback = isset($options['http_stats_receiver']) ? $options['http_stats_receiver'] : null;
     unset($options['http_stats_receiver']);
     // Remove unsupported options.
     foreach (array_keys($options) as $key) {
         if (!isset(self::$validOptions[$key])) {
             unset($options[$key]);
         }
     }
     // Handle delay option.
     if (isset($options['delay'])) {
         $ringConfig['delay'] = $options['delay'];
         unset($options['delay']);
     }
     // Prepare sink option.
     if (isset($options['sink'])) {
         $ringConfig['save_to'] = $options['sink'] instanceof Psr7StreamInterface ? new GuzzleStream($options['sink']) : $options['sink'];
         unset($options['sink']);
     }
     // Ensure that all requests are async and lazy like Guzzle 6.
     $options['future'] = 'lazy';
     // Create the Guzzle 5 request from the provided PSR7 request.
     $request = $this->client->createRequest($psrRequest->getMethod(), $psrRequest->getUri(), $options);
     if (is_callable($statsCallback)) {
         $request->getEmitter()->on('end', function (EndEvent $event) use($statsCallback) {
             $statsCallback($event->getTransferInfo());
         });
     }
     // For the request body, adapt the PSR stream to a Guzzle stream.
     $body = $psrRequest->getBody();
     if ($body->getSize() === 0) {
         $request->setBody(null);
     } else {
         $request->setBody(new GuzzleStream($body));
     }
     $request->setHeaders($psrRequest->getHeaders());
     $request->setHeader('User-Agent', $request->getHeader('User-Agent') . ' ' . Client::getDefaultUserAgent());
     // Make sure the delay is configured, if provided.
     if ($ringConfig) {
         foreach ($ringConfig as $k => $v) {
             $request->getConfig()->set($k, $v);
         }
     }
     return $request;
 }
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:47,代码来源:GuzzleHandler.php

示例6: __construct

 /**
  * The client constructor accepts the following options:.
  *
  * - api_provider: (callable) An optional PHP callable that accepts a
  *   type, service, and version argument, and returns an array of
  *   corresponding configuration data. The type value can be one of api,
  *   waiter, or paginator.
  * - client: (GuzzleHttp\ClientInterface) Optional Guzzle client used to
  *   transfer requests over the wire. If you do not specify a client, the
  *   SDK will create a new client that uses a shared Ring HTTP handler
  *   with other clients.
  * - credentials:
  *   (array|Vws\Credentials\CredentialsInterface|bool|callable) An
  *   Vws\Credentials\CredentialsInterface object to use with each, an
  *   associative array of "username", "password", and "subscription_token" key value pairs,
  *   `false` to utilize null credentials, or a callable credentials
  *   provider function to create credentials using a function. If no
  *   credentials are provided, the SDK will attempt to load them from the
  *   environment.
  * - debug: (bool|resource) Set to true to display debug information
  *   when sending requests. Provide a stream resource to write debug
  *   information to a specific resource.
  * - endpoint: (string) The full URI of the webservice. This is only
  *   required when connecting to a custom endpoint (e.g., a local version
  *   of S3).
  * - endpoint_provider: (callable) An optional PHP callable that
  *   accepts a hash of options including a service and region key and
  *   returns a hash of endpoint data, of which the endpoint key is
  *   required.
  * - http: (array) Set to an array of Guzzle client request options
  *   (e.g., proxy, verify, etc.). See
  *   http://docs.guzzlephp.org/en/latest/clients.html#request-options for a
  *   list of available options.
  * - profile: (string) Allows you to specify which profile to use when
  *   credentials are created from the Vws credentials file in your HOME
  *   directory. This setting overrides the Vws_PROFILE environment
  *   variable. Note: Specifying "profile" will cause the "credentials" key
  *   to be ignored.
  * - region: (string, required) Region to connect to.
  * - retries: (int, default=int(3)) Configures the maximum number of
  *   allowed retries for a client (pass 0 to disable retries).
  * - retry_logger: (string|Psr\Log\LoggerInterface) When the string "debug"
  *   is provided, all retries will be logged to STDOUT. Provide a PSR-3
  *   logger to log retries to a specific logger instance.
  * - ringphp_handler: (callable) RingPHP handler used to transfer HTTP
  *   requests (see http://ringphp.readthedocs.org/en/latest/).
  * - scheme: (string, default=string(5) "https") URI scheme to use when
  *   connecting connect.
  * - service: (string, required) Name of the service to utilize. This
  *   value will be supplied by default.
  * - validate: (bool, default=bool(true)) Set to false to disable
  *   client-side parameter validation.
  * - version: (string, required) The version of the webservice to
  *   utilize (e.g., 2006-03-01).
  *
  * @param array $args Client configuration arguments.
  *
  * @throws \InvalidArgumentException if any required options are missing
  */
 public function __construct(array $args)
 {
     list($service, $exceptionClass) = $this->parseClass();
     if (!isset($args['service'])) {
         $args['service'] = manifest($service)['endpoint'];
     }
     if (!isset($args['exception_class'])) {
         $this->commandException = $exceptionClass;
     }
     $resolver = new ClientResolver(static::getArguments());
     $config = $resolver->resolve($args, $this->getEmitter());
     $this->api = $config['api'];
     $this->serializer = $config['serializer'];
     $this->errorParser = $config['error_parser'];
     $this->endpoint = $config['endpoint'];
     $this->credentials = $config['credentials'];
     $this->region = isset($config['region']) ? $config['region'] : null;
     $this->applyParser();
     parent::__construct($config['client'], $config['config']);
     // Make sure the user agent is prefixed by the SDK version.
     $client = $this->getHttpClient();
     $client->setDefaultOption('allow_redirects', false);
     $client->setDefaultOption('headers/User-Agent', 'vws-sdk-php/' . Sdk::VERSION . ' ' . Client::getDefaultUserAgent());
     if (isset($args['with_resolved'])) {
         /* @var callable $withResolved */
         $args['with_resolved']($config);
     }
 }
开发者ID:ossistyle,项目名称:http-client-description,代码行数:87,代码来源:VwsClient.php

示例7: getDefaultUserAgent

 /**
  * Prepends the SDK's version number to the standard Guzzle string.
  *
  * @return string
  */
 public static function getDefaultUserAgent()
 {
     return sprintf("OpenStack/%f %s", Bootstrap::VERSION, Client::getDefaultUserAgent());
 }
开发者ID:ktroach,项目名称:openstack-sdk-php,代码行数:9,代码来源:GuzzleAdapter.php

示例8: getDefaultUserAgent

 public static function getDefaultUserAgent()
 {
     return 'OPCache/' . self::getDrupalModuleVersion() . ' ' . parent::getDefaultUserAgent();
 }
开发者ID:reload,项目名称:dockhub-testing,代码行数:4,代码来源:HTTPRequest.php


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