You are here

protected function Publisher::_getHttpClient in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/PubSubHubbub/Publisher.php \Zend\Feed\PubSubHubbub\Publisher::_getHttpClient()

Get a basic prepared HTTP client for use

Return value

\Zend\Http\Client

Throws

Exception\RuntimeException

2 calls to Publisher::_getHttpClient()
Publisher::notifyAll in vendor/zendframework/zend-feed/src/PubSubHubbub/Publisher.php
Notifies all Hub Server URLs of changes
Publisher::notifyHub in vendor/zendframework/zend-feed/src/PubSubHubbub/Publisher.php
Notifies a single Hub Server URL of changes

File

vendor/zendframework/zend-feed/src/PubSubHubbub/Publisher.php, line 372

Class

Publisher

Namespace

Zend\Feed\PubSubHubbub

Code

protected function _getHttpClient() {
  $client = PubSubHubbub::getHttpClient();
  $client
    ->setMethod(HttpRequest::METHOD_POST);
  $client
    ->setOptions([
    'useragent' => 'Zend_Feed_Pubsubhubbub_Publisher/' . Version::VERSION,
  ]);
  $params = [];
  $params[] = 'hub.mode=publish';
  $topics = $this
    ->getUpdatedTopicUrls();
  if (empty($topics)) {
    throw new Exception\RuntimeException('No updated topic URLs' . ' have been set');
  }
  foreach ($topics as $topicUrl) {
    $params[] = 'hub.url=' . urlencode($topicUrl);
  }
  $optParams = $this
    ->getParameters();
  foreach ($optParams as $name => $value) {
    $params[] = urlencode($name) . '=' . urlencode($value);
  }
  $paramString = implode('&', $params);
  $client
    ->setRawBody($paramString);
  return $client;
}