當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::getConfig方法代碼示例

本文整理匯總了PHP中Guzzle\Http\Client::getConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::getConfig方法的具體用法?PHP Client::getConfig怎麽用?PHP Client::getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Guzzle\Http\Client的用法示例。


在下文中一共展示了Client::getConfig方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getClient

 /**
  * @return Guzzle\Http\Client
  */
 public function getClient()
 {
     if (!isset($this->o_client)) {
         $this->o_client = new \Guzzle\Http\Client(self::NSL_SERVICES_URL, array('request.params' => array('cache.override_ttl' => 3600, 'params.cache.revalidate' => 'skip')));
         // can_cache needs to be callable
         $this->o_client->addSubscriber(new CachePlugin(array('storage' => new DefaultCacheStorage(new DoctrineCacheAdapter(new FilesystemCache(caGetTempDirPath()))), 'can_cache' => function () {
             // let's just cache for the above ttl
             return true;
         })));
         $o_conf = Configuration::load();
         if ($vs_proxy = $o_conf->get('web_services_proxy_url')) {
             /* proxy server is configured */
             $vo_config = $this->o_client->getConfig()->add('proxy', $vs_proxy);
             if (($vs_proxy_user = $o_conf->get('web_services_proxy_auth_user')) && ($vs_proxy_pass = $o_conf->get('web_services_proxy_auth_pw'))) {
                 $vo_config->add('curl.options', array(CURLOPT_PROXYUSERPWD => "{$vs_proxy_user}:{$vs_proxy_pass}"));
             }
         }
     }
     return $this->o_client;
 }
開發者ID:samrahman,項目名稱:providence,代碼行數:23,代碼來源:ALANSL.php

示例2: __construct

 public function __construct($username, $token, $client = null, $fragment = null)
 {
     parent::__construct('https://push.superfeedr.com');
     $this->username = $username;
     $this->token = $token;
     if ($client === null) {
         $client = new Guzzle\Http\Client();
     }
     $client->getConfig()->setPath('request.options/auth', [$username, $token]);
     $this->client = $client;
     if ($fragment !== null) {
         $this->fragment = $fragment;
     }
 }
開發者ID:taproot,項目名稱:subscriptions,代碼行數:14,代碼來源:SuperfeedrHub.php

示例3: getClient

 /**
  * @return \Guzzle\Http\Client
  */
 protected function getClient()
 {
     if ($this->client === null) {
         $this->client = new Client('https://bitbucket.org/api/1.0/');
         if ($this->authentication) {
             switch ($this->authentication->getType()) {
                 case AuthInterface::BASIC:
                     $this->client->getConfig()->setPath('request.options/auth', array($this->authentication->getUsername(), $this->authentication->getPassword(), 'Basic|Digest|NTLM|Any'));
                     break;
                 case AuthInterface::OAUTH:
                     // TODO
                     throw new \RuntimeException('Incomplete implementation');
                     break;
                 default:
                     throw new \RuntimeException(sprintf('Authentication via "%s" is not supported by bitbucket', $this->authentication->getType()));
             }
         }
     }
     return $this->client;
 }
開發者ID:contao-community-alliance,項目名稱:build-system-repositories,代碼行數:23,代碼來源:BitBucketProvider.php

示例4: testProperlyBlocksBasedOnRequestsInScope

 /**
  * @covers Guzzle\Http\Curl\CurlMulti
  */
 public function testProperlyBlocksBasedOnRequestsInScope()
 {
     $this->getServer()->flush();
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest1", "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest2", "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest3", "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest4", "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest5", "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\ntest6", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
     $client = new Client($this->getServer()->getUrl());
     $requests = array($client->get(), $client->get(), $client->get());
     // Sends 2 new requests in the middle of a CurlMulti loop while other requests
     // are completing.  This causes the scope of the multi handle to go up.
     $callback = function (Event $event) use($client) {
         $client->getConfig()->set('called', $client->getConfig('called') + 1);
         $request = $client->get();
         if ($client->getConfig('called') <= 2) {
             $request->getEventDispatcher()->addListener('request.complete', function (Event $event) use($client) {
                 $client->head()->send();
             });
         }
         $request->send();
     };
     $requests[0]->getEventDispatcher()->addListener('request.complete', $callback);
     $requests[1]->getEventDispatcher()->addListener('request.complete', $callback);
     $requests[2]->getEventDispatcher()->addListener('request.complete', $callback);
     $client->send($requests);
     $this->assertEquals(8, count($this->getServer()->getReceivedRequests(false)));
 }
開發者ID:MicroSDHC,項目名稱:justinribeiro.com-examples,代碼行數:27,代碼來源:CurlMultiTest.php

示例5: testHardResetReopensMultiHandle

 public function testHardResetReopensMultiHandle()
 {
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
     $stream = fopen('php://temp', 'w+');
     $client = new Client($this->getServer()->getUrl());
     $client->getConfig()->set('curl.CURLOPT_VERBOSE', true)->set('curl.CURLOPT_STDERR', $stream);
     $request = $client->get();
     $multi = new CurlMulti();
     $multi->add($request);
     $multi->send();
     $multi->reset(true);
     $multi->add($request);
     $multi->send();
     rewind($stream);
     $this->assertNotContains('Re-using existing connection', stream_get_contents($stream));
 }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:16,代碼來源:CurlMultiTest.php

示例6: testHasDefaultOptionsHelperMethods

 public function testHasDefaultOptionsHelperMethods()
 {
     $client = new Client();
     // With path
     $client->setDefaultOption('headers/foo', 'bar');
     $this->assertEquals('bar', $client->getDefaultOption('headers/foo'));
     // With simple key
     $client->setDefaultOption('allow_redirects', false);
     $this->assertFalse($client->getDefaultOption('allow_redirects'));
     $this->assertEquals(array('headers' => array('foo' => 'bar'), 'allow_redirects' => false), $client->getConfig('request.options'));
     $request = $client->get('/');
     $this->assertEquals('bar', $request->getHeader('foo'));
 }
開發者ID:carlesgutierrez,項目名稱:libreobjet.org,代碼行數:13,代碼來源:ClientTest.php

示例7: testCanSetDefaultRequestOptions

 public function testCanSetDefaultRequestOptions()
 {
     $client = new Client();
     $client->getConfig()->set('request.options', array('query' => array('test' => '123', 'other' => 'abc'), 'headers' => array('Foo' => 'Bar', 'Baz' => 'Bam')));
     $request = $client->createRequest('GET', 'http://www.foo.com?test=hello', array('Foo' => 'Test'));
     // Explicit options on a request should overrule default options
     $this->assertEquals('Test', (string) $request->getHeader('Foo'));
     $this->assertEquals('hello', $request->getQuery()->get('test'));
     // Default options should still be set
     $this->assertEquals('abc', $request->getQuery()->get('other'));
     $this->assertEquals('Bam', (string) $request->getHeader('Baz'));
 }
開發者ID:teenscode,項目名稱:invite,代碼行數:12,代碼來源:ClientTest.php

示例8: testCreatesRequestsWithDefaultValues

 /**
  * @covers Guzzle\Http\Client::createRequest
  */
 public function testCreatesRequestsWithDefaultValues()
 {
     $client = new Client($this->getServer()->getUrl() . 'base');
     // Create a GET request
     $request = $client->createRequest();
     $this->assertEquals('GET', $request->getMethod());
     $this->assertEquals($client->getBaseUrl(), $request->getUrl());
     // Create a DELETE request
     $request = $client->createRequest('DELETE');
     $this->assertEquals('DELETE', $request->getMethod());
     $this->assertEquals($client->getBaseUrl(), $request->getUrl());
     // Create a HEAD request with custom headers
     $request = $client->createRequest('HEAD', 'http://www.test.com/');
     $this->assertEquals('HEAD', $request->getMethod());
     $this->assertEquals('http://www.test.com/', $request->getUrl());
     // Create a PUT request
     $request = $client->createRequest('PUT');
     $this->assertEquals('PUT', $request->getMethod());
     // Create a PUT request with injected config
     $client->getConfig()->set('a', 1)->set('b', 2);
     $request = $client->createRequest('PUT', '/path/{a}?q={b}');
     $this->assertEquals($request->getUrl(), $this->getServer()->getUrl() . 'path/1?q=2');
 }
開發者ID:idiscussforum,項目名稱:providence,代碼行數:26,代碼來源:ClientTest.php

示例9: getDefaultOptions

 public function getDefaultOptions()
 {
     return $this->client->getConfig();
 }
開發者ID:canaltp,項目名稱:abstract-guzzle,代碼行數:4,代碼來源:Guzzle3.php

示例10: testAllowsCustomCacheFilterStrategies

 public function testAllowsCustomCacheFilterStrategies()
 {
     $plugin = new CachePlugin($this->adapter);
     $client = new Client($this->getServer()->getUrl(), array('params.cache.filter_strategy' => function ($request) {
         return true;
     }));
     $plugin->onRequestBeforeSend(new Event(array('request' => $client->post('/'))));
     $this->assertEquals(1, count($this->readAttribute($plugin, 'cached')));
     $client->getConfig()->set('params.cache.filter_strategy', function ($request) {
         return false;
     });
     $plugin->onRequestBeforeSend(new Event(array('request' => $client->get('/'))));
     $this->assertEquals(1, count($this->readAttribute($plugin, 'cached')));
 }
開發者ID:jsnshrmn,項目名稱:Suma,代碼行數:14,代碼來源:CachePluginTest.php

示例11: getGuzzleConfig

 /**
  * @param string|bool $key
  * @return \Guzzle\Common\Collection|mixed
  */
 public function getGuzzleConfig($key = false)
 {
     return $this->client->getConfig($key);
 }
開發者ID:webaction,項目名稱:php-geckoboard-api,代碼行數:8,代碼來源:Client.php

示例12: __construct

 /**
  * Create a new instance.
  *
  * @param string $user The transifex API user.
  *
  * @param string $pass The transifex API password.
  */
 public function __construct($user, $pass)
 {
     $this->client = new Client('http://www.transifex.com/api/2/');
     $this->client->getConfig()->setPath('request.options/auth', array($user, $pass, 'Basic'));
 }
開發者ID:cyberspectrum,項目名稱:contao-toolbox,代碼行數:12,代碼來源:Transport.php

示例13: getClient

 /**
  * @return \Guzzle\Http\Client
  */
 protected function getClient()
 {
     if ($this->client === null) {
         $this->client = new Client('https://api.github.com/');
         $this->client->setDefaultOption('headers/Accept', 'application/vnd.github.v3+json');
         if ($this->authentication) {
             switch ($this->authentication->getType()) {
                 case AuthInterface::BASIC:
                     $this->client->getConfig()->setPath('request.options/auth', array($this->authentication->getUsername(), $this->authentication->getPassword(), 'Basic|Digest|NTLM|Any'));
                     break;
                 case AuthInterface::ACCESS_TOKEN:
                     $this->client->setDefaultOption('headers/Authorization', 'token ' . $this->authentication->getAccessToken());
                     break;
                 default:
                     throw new \RuntimeException(sprintf('Authentication via "%s" is not supported by github', $this->authentication->getType()));
             }
         }
     }
     return $this->client;
 }
開發者ID:contao-community-alliance,項目名稱:build-system-repositories,代碼行數:23,代碼來源:GithubProvider.php


注:本文中的Guzzle\Http\Client::getConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。