xml news fethching

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sayee3k1
Forum Newbie
Posts: 20
Joined: Sat Feb 14, 2004 5:41 pm

xml news fethching

Post by sayee3k1 »

hai friends

I used the XML news fetch code in the EVILWALRUS website to display the news on my website.......

I have saved the follwing code in my server

it gives
fsockopen() error when i run it

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/sai/public_html/news/display1.php on line 6


any kind of suggestion will be great!!!!!!!!!!

i have also tried to set the directory in which i stored the code chmod 777

thanks


<?
// Insert URL of the rss/rdf file you want
// grabbing. BBC is the example given.

$rdf = parse_url("http://www.bbc.co.uk/syndication/feeds/ ... rss091.xml");
$fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
if (!$fp) {
$content = "<center><font class=\"content\">RSSPROBLEM</font></center>";
}
if ($fp) {
fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n");
fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
$string = "";
while(!feof($fp)) {
$pagetext = fgets($fp,300);
$string .= chop($pagetext);
}
fputs($fp,"Connection: close\r\n\r\n");
fclose($fp);
$items = explode("</item>",$string);
for ($i = 0; $i < 15; ++$i) {
$link = ereg_replace(".*<link>","",$items[$i]);
$link = ereg_replace("</link>.*","",$link);
$title2 = ereg_replace(".*<title>","",$items[$i]);
$title2 = ereg_replace("</title>.*","",$title2);
$description3 = ereg_replace(".*<description>","",$items[$i]);
$description3 = ereg_replace("</description>.*","",$description3);
$link = addslashes($link);
$title2 = addslashes($title2);
$description3 = addslashes($description3);
}
}

?>

urs
sai
Post Reply