You are here

public function FeedsHTTPFetcher::request in Feeds 7.2

Same name and namespace in other branches
  1. 6 plugins/FeedsHTTPFetcher.inc \FeedsHTTPFetcher::request()
  2. 7 plugins/FeedsHTTPFetcher.inc \FeedsHTTPFetcher::request()

Implements FeedsFetcher::request().

Overrides FeedsFetcher::request

File

plugins/FeedsHTTPFetcher.inc, line 152

Class

FeedsHTTPFetcher
Fetches data via HTTP.

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 {
    $source = feeds_source($this->id, $feed_nid);
    try {
      $source
        ->existing()
        ->import();
    } catch (Exception $e) {

      // In case of an error, respond with a 503 Service (temporary)
      // unavailable.
      $source
        ->log('import', 'An exception occurred: %exception', array(
        '%exception' => $e
          ->getMessage(),
      ), WATCHDOG_ERROR);
      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();
}