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