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


PHP Client::addSubscriber方法代码示例

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


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

示例1: __construct

 /**
  * Build a new FactoryDriver
  *
  * @param Container $app
  */
 public function __construct(Container $app)
 {
     $this->app = $app;
     $this->client = new \Guzzle\Http\Client();
     $cookiePlugin = new CookiePlugin(new ArrayCookieJar());
     $this->client->addSubscriber($cookiePlugin);
 }
开发者ID:victormacko,项目名称:trucker,代码行数:12,代码来源:RequestFactory.php

示例2: setUp

 protected function setUp()
 {
     $this->httpClient = new HttpClient('http://localhost');
     $this->clientMocker = new MockPlugin();
     $this->httpClient->addSubscriber($this->clientMocker);
     $this->engineClient = new EngineClient($this->httpClient, array('collection_name' => 'widgets'));
 }
开发者ID:benjy,项目名称:sajari-sdk-php,代码行数:7,代码来源:EngineClientTest.php

示例3: setGuzzle

 /**
  * @param \Guzzle\Http\Client $guzzle
  * @return void
  */
 public function setGuzzle(Client $guzzle)
 {
     $this->guzzle = $guzzle;
     $this->guzzle->setSslVerification(false, false);
     $this->guzzle->setUserAgent('User-Agent: Mozilla/5.0 (Linux; U; Android 4.3; EN; C6502 Build/10.4.1.B.0.101) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 PlayStation App/1.60.5/EN/EN');
     $this->guzzle->addSubscriber(new CookiePlugin(new ArrayCookieJar()));
 }
开发者ID:grit45,项目名称:gumer-psn-php,代码行数:11,代码来源:Connection.php

示例4: __construct

 /**
  * GuzzleHandler constructor.
  *
  * @param ConfigFacade|ConfigInterface $pConfig
  * @param InternalFactory $pFactory
  */
 public function __construct(ConfigInterface $pConfig, InternalFactory $pFactory)
 {
     $this->_config = $pConfig;
     $this->_factory = $pFactory;
     $this->_client = $this->_factory->getGuzzleFactory()->getHttpClientObject($this->_configurationOptions());
     $this->_client->addSubscriber($this->_factory->getGuzzleFactory()->getCookiePlugin());
 }
开发者ID:BertschiAG,项目名称:JRA,代码行数:13,代码来源:GuzzleHandler.php

示例5: setUp

 public function setUp()
 {
     // create client
     $this->_client = new \Guzzle\Http\Client('http://www.bing.com/');
     // add request sign plugin
     $this->_client->addSubscriber(new \Sokil\Guzzle\Plugin\RequestSign(array('key' => 'Shared secret key used for generating the HMAC variant of the message digest', 'additionalParams' => array('akey' => 'avalue'))));
 }
开发者ID:sokil,项目名称:php-guzzlecomponents,代码行数:7,代码来源:RequestSignTest.php

示例6: getHttpClient

 /**
  * 
  * @return \Guzzle\Http\Client
  */
 protected function getHttpClient()
 {
     if (is_null($this->httpClient)) {
         $this->httpClient = new HttpClient();
         $this->httpClient->addSubscriber(new \Guzzle\Plugin\History\HistoryPlugin());
     }
     return $this->httpClient;
 }
开发者ID:webignition,项目名称:website-rss-feed-finder,代码行数:12,代码来源:BaseTest.php

示例7: __construct

 public function __construct()
 {
     $this->guzzleClient = new Client();
     $this->logger = LogFactory::getLogger(get_class($this));
     if (!$this->logger instanceof NullLogger) {
         $logPlugin = new LogPlugin(new GuzzleLogAdapter(), MessageFormatter::DEFAULT_FORMAT);
         $this->guzzleClient->addSubscriber($logPlugin);
     }
 }
开发者ID:Javedwang,项目名称:bce-sdk-php,代码行数:9,代码来源:BceHttpClient.php

示例8: getClient

 /**
  * @return \Guzzle\Http\Client
  */
 protected function getClient()
 {
     if (is_null($this->client)) {
         $cookiePlugin = new CookiePlugin(new ArrayCookieJar());
         $this->client = new Client($this->parameters['base_url']);
         $this->client->addSubscriber($cookiePlugin);
     }
     return $this->client;
 }
开发者ID:calin-marian,项目名称:DrupalCommerceConnectorBundle,代码行数:12,代码来源:DrupalRestClient.php

示例9: testRegisterPlugin

 public function testRegisterPlugin()
 {
     $client = new Client('http://example.com');
     $client->addSubscriber($this->getPlugin());
     $mock = new MockPlugin();
     $mock->addResponse(new Response(200));
     $client->addSubscriber($mock);
     $request = $client->get('/resource/1');
     $request->send();
     $authorization = (string) $request->getHeader('Authorization');
     $this->assertRegExp('@Acquia 1:([a-zA-Z0-9+/]+={0,2})$@', $authorization);
 }
开发者ID:acquia,项目名称:hmac-request,代码行数:12,代码来源:Guzzle3AuthPluginTest.php

示例10: setCredentials

 /**
  * Set the consumer_key and consumer_secret for this instance.
  *
  * @param string $consumer_key The consumer_key of the twitter account.
  * @param string $consumer_secret The consumer_secret for the twitter account.
  * @param string $access_token_key The OAuth access token key value
  * @param string $access_token_secret The OAuth access token's secret
  */
 public function setCredentials($consumer_key, $consumer_secret, $access_token_key = null, $access_token_secret = null)
 {
     $this->setConsumerKey($consumer_key);
     $this->setConsumerSecret($consumer_secret);
     $this->setAccessTokenKey($access_token_key);
     $this->setAccessTokenSecret($access_token_secret);
     $this->oauth_consumer = null;
     if (!is_null($consumer_key) && !is_null($consumer_secret) && !is_null($access_token_key) && !is_null($access_token_secret)) {
         $oauth = new OauthPlugin(array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'token' => $access_token_key, 'token_secret' => $access_token_secret));
         $this->http_client->addSubscriber($oauth);
     }
 }
开发者ID:venkat554,项目名称:twitter-1,代码行数:20,代码来源:Api.php

示例11: getOAuthConnection

 /**
  * @param string $token
  * @param string $secret
  * @return Client
  */
 public function getOAuthConnection($token = null, $secret = null)
 {
     $client = new Client('https://api.twitter.com');
     $params = array('consumer_key' => $this->key, 'consumer_secret' => $this->secret);
     if ($token !== null && $secret !== null) {
         $params['token'] = $token;
         $params['token_secret'] = $secret;
     }
     $oauth = new OauthPlugin($params);
     $client->addSubscriber($oauth);
     if (null !== $this->logger) {
         $client->addSubscriber(new LogPlugin(new PsrLogAdapter($this->logger)));
     }
     return $client;
 }
开发者ID:derrabus,项目名称:twitter-signin-bundle,代码行数:20,代码来源:ConnectionFactory.php

示例12: create

 public static function create($host, $ssl, $clientID, $apiKey)
 {
     $guzzle = new GuzzleHttpClient(($ssl ? 'https' : 'http') . '://' . $host . '/');
     $signer = new RequestSigner($clientID, $apiKey);
     $guzzle->addSubscriber($signer);
     return new static($guzzle);
 }
开发者ID:dialogue1,项目名称:amity-client,代码行数:7,代码来源:Client.php

示例13: connect

 public function connect($errors = 0)
 {
     $client = new Client(null);
     if (!file_exists($this->_cookieFile)) {
         file_put_contents($this->_cookieFile, "");
     }
     $cookiePlugin = new CookiePlugin(new FileCookieJar($this->_cookieFile));
     $client->addSubscriber($cookiePlugin);
     $client->setUserAgent('User-Agent', 'Mozilla/5.0 (Linux; U; Android 4.2.2; de-de; GT-I9195 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30');
     $this->_client = $client;
     try {
         $url = $this->getLoginUrl();
         $this->loginAndGetCode($url);
         $this->enterAnswer();
         $this->gatewayMe();
         $this->auth();
         $this->getSid();
         $this->utasRefreshNucId();
         $this->auth();
         $this->utasAuth();
         $this->utasQuestion();
     } catch (\Exception $e) {
         throw $e;
         // server down, gotta retry
         if ($errors < static::RETRY_ON_SERVER_DOWN && preg_match("/service unavailable/mi", $e->getMessage())) {
             $this->connect(++$errors);
         } else {
             throw new \Exception('Could not connect to the mobile endpoint.');
         }
     }
     return array("nucleusId" => $this->nucId, "userAccounts" => $this->accounts, "sessionId" => $this->sid, "phishingToken" => $this->phishingToken, "platform" => $this->_loginDetails['platform']);
 }
开发者ID:hpreowned,项目名称:FIFA15-Unofficial-API,代码行数:32,代码来源:mobile_connector.php

示例14: connect

 public function connect($appKey, $appSecret, $accessToken, $tokenSecret)
 {
     try {
         $client = new Client(self::BASE_URL . '/{version}', ['version' => '1.1']);
         $oauth = new OauthPlugin(['consumer_key' => $appKey, 'consumer_secret' => $appSecret, 'token' => $accessToken, 'token_secret' => $tokenSecret]);
         return $client->addSubscriber($oauth);
     } catch (ClientErrorResponseException $e) {
         $req = $e->getRequest();
         $resp = $e->getResponse();
         print_r($resp);
         die('1');
     } catch (ServerErrorResponseException $e) {
         $req = $e->getRequest();
         $resp = $e->getResponse();
         die('2');
     } catch (BadResponseException $e) {
         $req = $e->getRequest();
         $resp = $e->getResponse();
         print_r($resp);
         die('3');
     } catch (Exception $e) {
         echo 'AGH!';
         die('4');
     }
 }
开发者ID:campaignchain,项目名称:channel-twitter,代码行数:25,代码来源:TwitterClient.php

示例15: Connect

 public function Connect()
 {
     $client = new Client(null);
     if (!file_exists($this->_cookieFile)) {
         file_put_contents($this->_cookieFile, "");
     }
     $cookiePlugin = new CookiePlugin(new FileCookieJar($this->_cookieFile));
     $client->addSubscriber($cookiePlugin);
     $client->setUserAgent("Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36");
     $this->_client = $client;
     $login_url = $this->GetMainPage($this->urls['main']);
     $this->Login($login_url);
     $nucleusId = $this->GetNucleusId($this->urls['nucleus']);
     $this->GetShards($nucleusId, $this->urls['shards']);
     $userAccounts = $this->GetUserAccounts($nucleusId, $this->urls['userinfo']);
     $sessionId = $this->GetSessionId($nucleusId, $userAccounts, $this->urls['session']);
     $phishing = $this->Phishing($nucleusId, $sessionId, $this->urls['phishing']);
     if (isset($phishing['debug']) && $phishing['debug'] == "Already answered question.") {
         $phishingToken = $phishing['token'];
     } else {
         $phishingToken = $this->Validate($nucleusId, $sessionId, $this->urls['validate']);
     }
     $this->_loginResponse = array("nucleusId" => $nucleusId, "userAccounts" => $userAccounts, "sessionId" => $sessionId, "phishingToken" => $phishingToken, "platform" => $this->_loginDetails['platform']);
     return $this->_loginResponse;
 }
开发者ID:hpreowned,项目名称:FIFA15-Unofficial-API,代码行数:25,代码来源:connector.php


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