Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// $Id$
/**
* @file
* Home of the FeedsHttpFetcher.
*
*/
/**
* Fetches data via HTTP.
*/
class FeedsHttpFetcher extends FeedsFetcher {
/**
* Fetch a resource via http.
*
* @todo: Use Curl, fall back to drupal_http_request.
* @todo: Add caching.
*
* @param $resource
* A resource description of type FeedsResource.
*
* @return
* A string from the requested location if successful, or FALSE if not.
*/
public function fetch($resource) {
if ($resource->type == 'http') {
$result = drupal_http_request($resource->identifier);
$count = 0;
while ($result->redirect_url) {
$result = drupal_http_request($result->redirect_url);
$count++;
if ($count > 100) {
return FALSE;
}
}
if (!$result->error) {
return $result->response;
}
return FALSE;
}
}
}