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


PHP self::setDefaultOption方法代码示例

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


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

示例1: factory

 public static function factory($config = array())
 {
     // The following values are required when creating the client
     $required = array('base_url', 'username', 'password');
     // Merge in default settings and validate the config
     $config = Collection::fromConfig($config, array(), $required);
     // Create a new sData client
     $client = new self($config->get('base_url'), $config);
     // JSON by default
     $client->setDefaultOption('query/format', 'json');
     // Authentication
     $client->setDefaultOption('auth', array($config->get('username'), $config->get('password'), 'Basic'));
     // Strip the BOM from results
     $client->addSubscriber(new StripBomPlugin());
     // Optional logging
     if ($config->get('log')) {
         $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) {
             $req = $event['request'];
             \Log::info('sData', ['request' => $req->getMethod() . ' ' . $req->getResource()]);
         });
     }
     // Set the service description
     $services = \Config::get('sdata::services');
     if (!empty($services)) {
         $client->setDescription(ServiceDescription::factory($services));
     }
     // Done
     return $client;
 }
开发者ID:cviebrock,项目名称:sdata-laravel,代码行数:29,代码来源:Sdata.php

示例2: factory

 /**
  * Static factory method used to turn an array or collection of configuration data into an instantiated object.
  *
  * @param array|Collection $config Configuration data
  * @return KinveyClient
  */
 public static function factory($config = array())
 {
     $client = new self($config['baseURL'], $config);
     $client->setDefaultOption('headers/Content-Type', 'application/json');
     $client->setDefaultOption('X-Kinvey-API-Version', 2);
     $client->setAuthMode($config['defaultAuthMode']);
     $client = self::registerPlugins($client);
     return $client;
 }
开发者ID:tvpsoft,项目名称:laravel-kinvey,代码行数:15,代码来源:KinveyClient.php

示例3: factory

 public static function factory($config = array())
 {
     // provide a hash of default client configuration options
     $default = array('base_url' => 'http://127.0.0.1/', 'api_id' => 1, 'private_key' => 'fbdce19f94b158e72ae6020cc5126642a9d42d086419c015ad2b6dd429312410');
     // the following values are required when creating the client
     $required = array('base_url', 'api_id', 'private_key');
     // merge in default settings and validate the config
     $config = \Guzzle\Common\Collection::fromConfig($config, $default, $required);
     // create a new client
     $client = new self($config->get('base_url'), $config);
     $client->setDefaultOption('headers/API_ID', $config->get('api_id'));
     $client->getEventDispatcher()->addListener('client.create_request', function (\Guzzle\Common\Event $event) use($config) {
         // Guzzle\Http\Message\Request
         $data = $event['request']->getQuery();
         // Guzzle\Http\Message\EntityEnclosingRequest
         if ($event['request'] instanceof Guzzle\Http\Message\EntityEnclosingRequest) {
             $data->overwriteWith($event['request']->getPostFields());
         }
         $time = (string) time();
         $message = $time . $config->get('api_id') . implode($data->toArray());
         $hash = hash_hmac('sha256', $message, $config->get('private_key'));
         $event['request']->setHeader('API_TIME', $time)->setHeader('API_HASH', $hash);
         unset($data, $time, $message, $hash);
     });
     return $client;
 }
开发者ID:flyingbuddha,项目名称:eyas,代码行数:26,代码来源:TestClient.php

示例4: factory

 /**
  * {@inheritdoc}
  */
 public static function factory($config = array())
 {
     $default = array('url' => false, 'munchkin_id' => false, 'version' => 1, 'bulk' => false);
     $required = array('client_id', 'client_secret', 'version');
     $config = Collection::fromConfig($config, $default, $required);
     $url = $config->get('url');
     if (!$url) {
         $munchkin = $config->get('munchkin_id');
         if (!$munchkin) {
             throw new \Exception('Must provide either a URL or Munchkin code.');
         }
         $url = sprintf('https://%s.mktorest.com', $munchkin);
     }
     $grantType = new Credentials($url, $config->get('client_id'), $config->get('client_secret'));
     $auth = new Oauth2Plugin($grantType);
     if ($config->get('bulk') === true) {
         $restUrl = sprintf('%s/bulk/v%d', rtrim($url, '/'), $config->get('version'));
     } else {
         $restUrl = sprintf('%s/rest/v%d', rtrim($url, '/'), $config->get('version'));
     }
     $client = new self($restUrl, $config);
     $client->addSubscriber($auth);
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/service.json'));
     $client->setDefaultOption('headers/Content-Type', 'application/json');
     return $client;
 }
开发者ID:arkadedigital,项目名称:marketo-rest-api,代码行数:29,代码来源:Client.php

示例5: factory

 /**
  * Creates a client token auth client with the supplied configuration options
  *
  * @param array $config
  * @return Client|IntercomBasicAuthClient
  */
 public static function factory($config = [])
 {
     $client = new self();
     $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required);
     $client->configure($config);
     $client->setBasicAuth($config->get('client_uuid'), $config->get('client_key'));
     $client->setDefaultOption('query/app_id', $config->get('app_id'));
     return $client;
 }
开发者ID:nurazem,项目名称:intercom-php,代码行数:15,代码来源:IntercomClientTokenAuthClient.php

示例6: factory

 /**
  * Creates a client token auth client with the supplied configuration options
  *
  * @param array $config
  * @return Client|IntercomBasicAuthClient
  */
 public static function factory($config = array())
 {
     $client = new self();
     $config = Collection::fromConfig($config, $client->getDefaultConfig(), static::$required);
     $client->configure($config);
     $client->setBasicAuth($config->get('client_uuid'), $config->get('client_key'));
     $client->setUserAgent('intercom-php/1.4.0', true);
     $client->setDefaultOption('query/app_id', $config->get('app_id'));
     return $client;
 }
开发者ID:scup,项目名称:intercom-php,代码行数:16,代码来源:IntercomClientTokenAuthClient.php

示例7: factory

 public static function factory($config = array())
 {
     $config = Collection::fromConfig($config, self::getDefaultConfig(), ['api_token', 'service_description']);
     $client = new self($config->get('base_url'), $config);
     $client->setDescription($client->getServiceDescriptionFromFile($config->get('service_description')));
     $client->setDefaultOption('auth', [$config->get('api_token'), null, 'basic']);
     $client->addSubscriber($client);
     $client->setErrorHandler();
     return $client;
 }
开发者ID:karllhughes,项目名称:clearbit-php,代码行数:10,代码来源:Client.php

示例8: factory

 /**
  * Factory method to create a new Bitpay client
  *
  * @param array $config
  *
  * @return BitpayClient
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://bitpay.com/api');
     $required = array('apiKey');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
     $client->setDefaultOption('auth', array($config['apiKey'], '', 'Basic'));
     return $client;
 }
开发者ID:symm,项目名称:guzzle-bitpay,代码行数:17,代码来源:BitpayClient.php

示例9: factory

 public static function factory($config = array())
 {
     $default = array('base_url' => '');
     $required = array('base_url', 'scheme', 'auth_token', 'service');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $description = ServiceDescription::factory(__DIR__ . '/Resources/search.json');
     $client->setDescription($description);
     $client->setDefaultOption('query', array('auth_token' => $config->get('auth_token')));
     return $client;
 }
开发者ID:r-baker,项目名称:3taps-php-client,代码行数:11,代码来源:SearchClient.php

示例10: factory

 /**
  * {@inheritDoc}
  */
 public static function factory($config = array())
 {
     $defaultOptions = array('base_url' => '{scheme}://{hostname}', 'hostname' => 'api.mgrt.net', 'scheme' => 'https');
     $requiredOptions = array('public_key', 'private_key');
     $config = Collection::fromConfig($config, $defaultOptions, $requiredOptions);
     $description = ServiceDescription::factory(__DIR__ . '/Resources/service.php');
     $client = new self($config->get('base_url'), $config);
     $client->setDefaultOption('auth', array($config['public_key'], $config['private_key'], 'Basic'));
     $client->setDescription($description);
     $client->setUserAgent(sprintf('mgrt-php/%s guzzle/%s PHP/%s', \Mgrt\Version::VERSION, \Guzzle\Common\Version::VERSION, PHP_VERSION));
     return $client;
 }
开发者ID:mgrt,项目名称:mgrt-php,代码行数:15,代码来源:Client.php

示例11: factory

 /**
  * Factory method to create the client
  *
  * @param  array                  $config
  * @return Client|SparkreelClient
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://{hostname}/v1', 'scheme' => 'https', 'hostname' => 'api.sparkreel.com');
     $required = array('base_url', 'api_key');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     // set X-API-Key header
     $client->setDefaultOption('headers/X-API-Key', $config->get('api_key'));
     // Attach a service description to the client
     $description = ServiceDescription::factory(__DIR__ . '/Resources/v0.json');
     $client->setDescription($description);
     return $client;
 }
开发者ID:sparkreel,项目名称:sdk,代码行数:19,代码来源:SparkreelClient.php

示例12: factory

 /**
  * Factory method to create the client
  *
  * @param  array  $config
  * @return Client
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://{hostname}/oauth', 'scheme' => 'https', 'hostname' => 'www.sparkreel.com');
     $required = array('base_url', 'client_id', 'client_secret');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     // Attach a service description to the client
     $description = ServiceDescription::factory(dirname(__DIR__) . '/Resources/OAuth2.json');
     $client->setDescription($description);
     // send client_id & client_secret as Basic auth
     $client->setDefaultOption('auth', array($config->get('client_id'), $config->get('client_secret'), 'Basic'));
     return $client;
 }
开发者ID:sparkreel,项目名称:sdk,代码行数:19,代码来源:Client.php

示例13: factory

 public static function factory($config = array())
 {
     $default = array('host' => 'api.trak.io/v1', 'https' => true);
     $config = array_merge($config, $default);
     $required = array('token', 'host', 'https');
     self::validate($required, $config);
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self(($config->get('https') ? 'https://' : 'http://') . $config->get('host'), $config);
     $client->setDefaultOption('headers/X-Token', $config->get('token'));
     $config->hasKey('distinct_id') ? $client->distinct_id($config->get('distinct_id')) : null;
     $config->hasKey('channel') ? $client->channel($config->get('channel')) : null;
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/Resources/config/client.json'));
     return $client;
 }
开发者ID:cossou,项目名称:trak-io-api-client,代码行数:14,代码来源:Trakio.php

示例14: factory

 public static function factory($config = array())
 {
     // Provide a hash of default client configuration options
     $default = array('base_url' => 'https://maps.googleapis.com/maps/api/place');
     // The following values are required when creating the client
     $required = array('key');
     // Merge in default settings and validate the config
     $config = Collection::fromConfig($config, $default, $required);
     // Create a new Google Places API Client
     $client = new self($config->get('base_url'), $config);
     $client->setDefaultOption('query', array('key' => $config['key'], 'language' => $config['language']));
     // Set the service description
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/../config/service_description.json'));
     return $client;
 }
开发者ID:felds,项目名称:google-places-api-client,代码行数:15,代码来源:GooglePlacesAPIClient.php

示例15: factory

 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://api.foursquare.com/v2/');
     $required = array('client_id', 'client_secret');
     foreach ($required as $value) {
         if (empty($config[$value])) {
             throw new InvalidArgumentException("Argument '{$value}' must not be blank.");
         }
     }
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->setDefaultOption('query', array('client_id' => $config['client_id'], 'client_secret' => $config['client_secret'], 'v' => '20130707'));
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/../Resources/config/client.json'));
     return $client;
 }
开发者ID:ktardthong,项目名称:beerhit,代码行数:15,代码来源:FoursquareClient.php


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