In using the aggregator in 4.7.4 I'm trying to use a feed from a local file rather than on another server. I keep getting "invlid schema" messages. I've tried naming the file dot rss and dot xml with no luck. The file is very simple for testing purposes and I've looked and looked at possible syntax errors but it seems to be clean as a whistle. I know Drupal can read files from that directory, which is below the html directory, because I can include content from another file there in a Drupal story. The aggregator will present feeds from other servers just fine. Is there some trick to persuading the Drupal aggregator to present a feed in a local file?

Comments

mlcc2000’s picture

Was looking to do the same. Wanted to know if you were successful and what you had to do?

paul6299’s picture

Paul W in L.A. (somewhere south of Hollywood)

mlcc2000’s picture

After much trial and error, I came up with a mod to read a local xml into the aggregator. Not sure if this is the best way, but it seems to work. Here is what I did:

  • Created a directory to put the rss file into.
  • Modified common.inc to read a local file instead of over the net. Mods are in bold below
  • Configured the feed. In the URL use local:// instead of http://

Let me know if this works for you.

..common.inc...

.
.
.
.
function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
$result = new StdClass();

// Parse the URL, and make sure we can handle the schema.
$uri = parse_url($url);
switch ($uri['scheme']) {
case 'http':
$port = isset($uri['port']) ? $uri['port'] : 80;
$host = $uri['host'] . ($port != 80 ? ':'. $port : '');
if (variable_get('proxy_name', '')) {
$fp = @fsockopen(variable_get('proxy_name', ''), variable_get('proxy_port', ''));
} else {
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
}
break;
case 'https':
// Note: Only works for PHP 4.3 compiled with OpenSSL.
$port = isset($uri['port']) ? $uri['port'] : 443;
$host = $uri['host'] . ($port != 443 ? ':'. $port : '');
$fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
break;
case 'local':
// Added to support local RSS Feed File import
$fp = fopen('d:/rss_folder/' . $uri['host'], 'rb'); // Opens file for read only
// Fetch response.
$response = '';
while (!feof($fp) && $chunk = fread($fp, 1024)) {
$response .= $chunk;
}
fclose($fp);
// Parse response.
$result->data = $response;
$result->error = $text;
$result->code = '200';
return $result;
break;
// End Mods

default:
$result->error = 'invalid schema during https '. $uri['scheme'];
return $result;
}

mlcc2000

paul6299’s picture

Will give it a try.

Paul W in L.A. (somewhere south of Hollywood)

mlcc2000’s picture

I reviewed my previous post and noticed that I didn't bold a pretty important line. Included in the bold should also be

case 'local':

Sorry if this caused any problems.

Good luck and let me know your results.

mlcc2000