Rss parsing works on local server, doesn't work on

apps

#1

Hi,

I’ve a RSS parsing engine which works fine on my local server - but doesn’t work on DH.
The function which gives error is:

function parse ($feed)
{
$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
$rss_parser->setFeedId($feed[“feed_id”]);
$rss_parser->setLastPubDate($feed[“last_pub_date”]);

xml_set_object($xml_parser,$rss_parser);
xml_set_element_handler($xml_parser, “startElement”, “endElement”);
xml_set_character_data_handler($xml_parser, “characterData”);
if (!$fp = fopen($feed[“feed_url”],“r”)) {
//something wrong with the connection
echo("Error reading RSS data from $feed[feed_name] - $feed[feed_url]
");
updateFeed($feed, “C”, $feed[“last_pub_date”]);
return;
}
while ($data = fread($fp, 9096))
if(!xml_parse($xml_parser, $data, feof($fp))) {
//something wrong with the xml itself
echo(sprintf(“XML error: %s at line %d”,
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
updateFeed($feed, “X”, $feed[“last_pub_date”]);
fclose($fp);
return;
}
fclose($fp);
xml_parser_free($xml_parser);
//if we got this far we’ll assume that we were successful
$last_pub = date(“Y-m-d H:i:s”, $rss_parser->new_pub_date);
updateFeed($feed, “Y”, $last_pub);
}

end the error is:

Error reading RSS data from Google - http://news.google.ie/nwshp?
hl=en&tab=wn&q=&output=rss

Error reading RSS data from Piaras Kelly PR - http://pkellypr.com/blog/feed/

etc.

I tried changing PHPversion and cgi/apache mode but that didn’t help. I also tried
changing ‘http://’ to ‘feed://’ in a feed_url but with no results as well.

function is good for sure, as it works fine on my local server and on letshost.ie server as
well. What is then a reason?

thank You in advance


#2

http://wiki.dreamhost.com/index.php/Allow_url_fopen