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


PHP ClientInterface::addSubscriber方法代码示例

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


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

示例1: __construct

 /**
  * @param string $projectname
  * @param string $username
  * @param string $password
  * @param ClientInterface $httpClient
  */
 public function __construct($projectname, $username, $password, ClientInterface $httpClient = null)
 {
     $this->projectname = $projectname;
     $this->username = $username;
     $this->password = $password;
     $this->httpClient = $httpClient ?: new GuzzleClient();
     $this->httpClient->addSubscriber($this);
 }
开发者ID:nicmart,项目名称:getlocalization,代码行数:14,代码来源:Client.php

示例2: __construct

 /**
  * @param ClientInterface $client Client object
  */
 public function __construct(ClientInterface $client = null)
 {
     $this->requests = array();
     if (!$client) {
         $this->client = new Client();
         $cache = new CachePlugin(array('storage' => new DefaultCacheStorage(new DoctrineCacheAdapter(new FilesystemCache(sys_get_temp_dir())))));
         $this->client->addSubscriber($cache);
     } else {
         $this->client = $client;
     }
 }
开发者ID:mhlavac,项目名称:GeonamesBundle,代码行数:14,代码来源:GuzzleDownloadAdapter.php

示例3: setUp

 protected function setUp()
 {
     Phake::initAnnotations($this);
     Phake::when($this->cryptService)->encryptRSA(Phake::anyParameters())->thenReturn($this->rsaEncrypted);
     Phake::when($this->cryptService)->sign(Phake::anyParameters())->thenReturn($this->signed);
     Phake::when($this->cache)->get(GuzzleApiService::CACHE_KEY_PUBLIC_KEY)->thenReturn($this->publicKey);
     $this->guzzleClient = new Client();
     $this->guzzleMockPlugin = new MockPlugin();
     $this->guzzleClient->addSubscriber($this->guzzleMockPlugin);
     $this->apiService = new GuzzleApiService($this->appKey, $this->secretKey, $this->guzzleClient, $this->cryptService, $this->cache, 999999);
     $this->loggingApiService = new GuzzleApiService($this->appKey, $this->secretKey, $this->guzzleClient, $this->cryptService, $this->cache, 999999, $this->logger);
 }
开发者ID:ThemeSurgeon,项目名称:launchkey-php,代码行数:12,代码来源:GuzzleApiServiceTestAbstract.php

示例4: __construct

 public function __construct(ClientInterface $client = null)
 {
     $this->client = $client;
     if (!$this->client) {
         $this->client = new Client();
         $this->client->getEventDispatcher()->addListener('request.error', function (Event $event) {
             // override guzzle default behavior of throwing exceptions
             // when 4xx & 5xx responses are encountered
             $event->stopPropagation();
         }, -254);
         $this->client->addSubscriber(BackoffPlugin::getExponentialBackoff(5, array(500, 502, 503, 408)));
     }
 }
开发者ID:aztech-dev,项目名称:Zippy,代码行数:13,代码来源:LegacyGuzzleReaderFactory.php

示例5: __construct

 /**
  * @param array $configs
  * @param ClientInterface $client
  * @param LoggerInterface $logger
  */
 protected function __construct(array $configs, ClientInterface $client = null, LoggerInterface $logger = null)
 {
     $configs = array_merge($this->getDefaultConfig(), $configs);
     $this->setCredentials($configs);
     $this->setDefaults();
     if ($configs['auth_in_header']) {
         $this->headers['Authorization'] = $this->getAuthHeader();
     }
     $this->logger = $logger ?: new NullLogger();
     $this->client = $client ?: new Client();
     $this->client->setBaseUrl($configs['base_url']);
     $this->client->addSubscriber(new LogPlugin(new PsrLogAdapter($this->logger)));
     $this->tokenRequestPath = $configs['token_request_path'];
 }
开发者ID:careerbuilder,项目名称:php-oauth,代码行数:19,代码来源:Flow.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param ClientInterface $httpClient
  * @param array           $options
  * @param LoggerInterface $logger
  */
 public function __construct(ClientInterface $httpClient, array $options, LoggerInterface $logger = null)
 {
     $this->httpClient = $httpClient;
     $scheme = isset($options['scheme']) ? $options['scheme'] : static::DEFAULT_SCHEME;
     $host = isset($options['host']) ? $options['host'] : static::DEFAULT_HOST;
     $port = isset($options['port']) ? $options['port'] : static::DEFAULT_PORT;
     $pathPrefix = isset($options['path_prefix']) ? $options['path_prefix'] : static::DEFAULT_PATH_PREFIX;
     $accessKey = isset($options['access_key']) ? $options['access_key'] : null;
     $secretKey = isset($options['secret_key']) ? $options['secret_key'] : null;
     $this->scheme = $scheme;
     $this->host = $host;
     $this->port = $port;
     $this->pathPrefix = $pathPrefix;
     $this->accessKey = $accessKey;
     $this->secretKey = $secretKey;
     $this->companyName = isset($options['company']) ? $options['company'] : null;
     $this->collectionName = isset($options['collection']) ? $options['collection'] : null;
     $this->options = $options;
     $this->logger = $logger;
     $exceptionFactory = new NamespaceExceptionFactory(new EngineExceptionParser(), 'Sajari\\Engine\\Exception', 'Sajari\\Engine\\Exception\\EngineException');
     $this->httpClient->addSubscriber(new StatusCodeListener());
     $this->httpClient->addSubscriber(new ExceptionListener($exceptionFactory));
     $connectTimeout = 10;
     $timeout = 10;
     if (isset($this->options['curl.options']['CURLOPT_CONNECTTIMEOUT'])) {
         $connectTimeout = (int) $this->options['curl.options']['CURLOPT_CONNECTTIMEOUT'];
     }
     if (isset($this->options['curl.options']['CURLOPT_TIMEOUT'])) {
         $timeout = (int) $this->options['curl.options']['CURLOPT_TIMEOUT'];
     }
     $this->httpClient->setBaseUrl(sprintf('%s://%s', $this->scheme, $this->host));
     $this->httpClient->setConfig(array(HttpClient::SSL_CERT_AUTHORITY => false, HttpClient::CURL_OPTIONS => array(CURLOPT_CONNECTTIMEOUT => $connectTimeout, CURLOPT_TIMEOUT => $timeout)));
 }
开发者ID:benjy,项目名称:sajari-sdk-php,代码行数:40,代码来源:EngineClient.php

示例7: addPsrLoggerToClient

 /**
  * @param ClientInterface $client
  * @param LoggerInterface $logger
  * @param null|string $formatter
  * @return LogPlugin
  */
 public static function addPsrLoggerToClient(ClientInterface $client, LoggerInterface $logger, $formatter = self::SIMPLE_FORMAT)
 {
     $formatter = is_null($formatter) ? self::SIMPLE_FORMAT : $formatter;
     $adapter = new PsrLogAdapter($logger);
     $plugin = new LogPlugin($adapter, $formatter);
     $client->addSubscriber($plugin);
     return $plugin;
 }
开发者ID:subscribo,项目名称:omnipay-subscribo-shared,代码行数:14,代码来源:GuzzleClientHelper.php

示例8: testGetByAccessToken_Invalid

 public function testGetByAccessToken_Invalid()
 {
     $user = $this->createUser();
     $this->user_service->save($user);
     $mock_plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock_plugin->addResponse(new \Guzzle\Http\Message\Response(200, [], json_encode(['id' => 2])));
     $this->http->addSubscriber($mock_plugin);
     $this->assertNull($this->user_service->getByAccessToken('invalid_token'));
 }
开发者ID:shina,项目名称:control-my-budget,代码行数:9,代码来源:UserServiceTest.php

示例9: setupOAuth2Plugin

 /**
  * setting up the oauth2 plugin for authorizing the requests
  */
 private function setupOAuth2Plugin()
 {
     $oauth2AuthorizationClient = $this->resolveClient(null);
     $oauth2AuthorizationClient->setBaseUrl(Properties::authorizationUrl());
     $clientCredentials = new ClientCredentials($oauth2AuthorizationClient, $this->config->toArray());
     $oauth2Plugin = new OAuth2Plugin($clientCredentials);
     $oauth2Plugin->setCache($this->config->getAccessTokenCacheFile());
     $this->client->addSubscriber($oauth2Plugin);
 }
开发者ID:double-opt-in,项目名称:php-client-api,代码行数:12,代码来源:Api.php

示例10: addSubscriber

 /**
  * Add a subscriber
  *
  * @param EventSubscriberInterface $subscriber
  */
 public function addSubscriber(EventSubscriberInterface $subscriber)
 {
     $this->client->addSubscriber($subscriber);
 }
开发者ID:n10ty,项目名称:api,代码行数:9,代码来源:HttpClient.php


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