当前位置: 首页>>代码示例>>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;未经允许,请勿转载。