943,746 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5775
  • PHP RSS
Apr 20th, 2009
0

simplexml_load_file() function error

Expand Post »
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:
php Syntax (Toggle Plain Text)
  1. failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable in

My code is like this:
php Syntax (Toggle Plain Text)
  1. $zip = 10001;
  2. $url = "http://news.google.com/news?pz=1&ned=us&hl=en&q=".$zip."&output=rss";
  3. $rss = simplexml_load_file($url);

Where is the problem??
Many Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster
shasha821110 is offline Offline
123 posts
since Jan 2009
Apr 20th, 2009
0

Re: simplexml_load_file() function error

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

php Syntax (Toggle Plain Text)
  1. $zip = 10001;
  2. $url = "http://news.google.com/news?pz=1&ned=us&hl=en&q=".$zip."&output=rss";
  3.  
  4. $ch = curl_init();
  5. $timeout = 5; // set to zero for no timeout
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  9. $result = curl_exec($ch);
  10. curl_close($ch);
  11.  
  12. $rss = simplexml_load_string($result);
Reputation Points: 52
Solved Threads: 23
Posting Whiz in Training
martin5211 is offline Offline
271 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Add GD Function
Next Thread in PHP Forum Timeline: mysql_real_esc_str expecting string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC