Hi, all
I am using simplexml_load_file() function to get the rss and change it to the XML and get the elements.
But i got the error information like below:

failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in

My code is like this:

$zip = 10001;
$url = "http://news.google.com/news?pz=1&ned=us&hl=en&q=".$zip."&output=rss";
$rss = simplexml_load_file($url);

Where is the problem??
Many Thanks.

Use CURL or fsockopen() to get the result from Google, then simplexml_load_string()

$zip = 10001;
$url = "http://news.google.com/news?pz=1&ned=us&hl=en&q=".$zip."&output=rss";

$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);

$rss = simplexml_load_string($result);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.