You are here

public function FeedsHTTPFetcher::request in Feeds 8.2

Implements FeedsFetcher::request().

Overrides FeedsFetcher::request

File

lib/Drupal/feeds/Plugin/feeds/fetcher/FeedsHTTPFetcher.php, line 59
Contains \Drupal\feeds\Plugin\feeds\fetcher\FeedsHTTPFetcher.

Class

FeedsHTTPFetcher
Defines an HTTP fetcher.

Namespace

Drupal\feeds\Plugin\feeds\fetcher

Code

public function request($feed_nid = 0) {
  feeds_dbg($_GET);
  @feeds_dbg(file_get_contents('php://input'));

  // A subscription verification has been sent, verify.
  if (isset($_GET['hub_challenge'])) {
    $this
      ->subscriber($feed_nid)
      ->verifyRequest();
  }
  else {
    try {
      feeds_source($this->id, $feed_nid)
        ->existing()
        ->import();
    } catch (Exception $e) {

      // In case of an error, respond with a 503 Service (temporary) unavailable.
      header('HTTP/1.1 503 "Not Found"', NULL, 503);
      drupal_exit();
    }
  }

  // Will generate the default 200 response.
  header('HTTP/1.1 200 "OK"', NULL, 200);
  drupal_exit();
}