You are here

protected function Subscriber::_doRequest in Zircon Profile 8.0

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

Executes an (un)subscribe request

Parameters

string $mode:

Return value

void

Throws

Exception\RuntimeException

2 calls to Subscriber::_doRequest()
Subscriber::subscribeAll in vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber.php
Subscribe to one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)
Subscriber::unsubscribeAll in vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber.php
Unsubscribe from one or more Hub Servers using the stored Hub URLs for the given Topic URL (RSS or Atom feed)

File

vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber.php, line 605

Class

Subscriber

Namespace

Zend\Feed\PubSubHubbub

Code

protected function _doRequest($mode) {
  $client = $this
    ->_getHttpClient();
  $hubs = $this
    ->getHubUrls();
  if (empty($hubs)) {
    throw new Exception\RuntimeException('No Hub Server URLs' . ' have been set so no subscriptions can be attempted');
  }
  $this->errors = [];
  $this->asyncHubs = [];
  foreach ($hubs as $url) {
    if (array_key_exists($url, $this->authentications)) {
      $auth = $this->authentications[$url];
      $client
        ->setAuth($auth[0], $auth[1]);
    }
    $client
      ->setUri($url);
    $client
      ->setRawBody($params = $this
      ->_getRequestParameters($url, $mode));
    $response = $client
      ->send();
    if ($response
      ->getStatusCode() !== 204 && $response
      ->getStatusCode() !== 202) {
      $this->errors[] = [
        'response' => $response,
        'hubUrl' => $url,
      ];

      /**
       * At first I thought it was needed, but the backend storage will
       * allow tracking async without any user interference. It's left
       * here in case the user is interested in knowing what Hubs
       * are using async verification modes so they may update Models and
       * move these to asynchronous processes.
       */
    }
    elseif ($response
      ->getStatusCode() == 202) {
      $this->asyncHubs[] = [
        'response' => $response,
        'hubUrl' => $url,
      ];
    }
  }
}