Empty RSS results
Why this code results empty in my hosting, but works well in my local?
$raw = file_get_contents($rssURL);
$xml = new SimpleXmlElement($raw);
echo "<b>RSS Items:</b><br /><br />";
foreach($xml->channel->item as $item) {
echo $item->title."</br >";
}
libxml
version: 2.6.32; libxml2
version: 2.6.32
I also tried this code:
# INSTANTIATE CURL.
$curl = curl_init();
# CURL SETTINGS.
curl_setopt($curl, CURLOPT_URL, $rssURL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
# GRAB THE XML FILE.
$xml = curl_exec($curl);
curl_clo开发者_C百科se($curl);
# SET UP XML OBJECT.
$xmlObj = simplexml_load_string($xml);
echo "<b>RSS Items:</b><br /><br />";
foreach($xmlObj->channel->item as $item) {
echo $item->title."</br >";
}
echo "<br /><b>var_dump:</b><br><br>";
var_dump(libxml_get_errors())
The result was array(0) { }
Is there any differences between coding this snippet for Windows and Linux (I don't think so)?
Any Idea's?
Start with http://www.php.net/manual/en/function.libxml-get-errors.php and find out what errors simplexml_load_string() is throwing since it returns false on error.
Also, your provider might not let you make outside calls from your software, just a thought.
I use godaddy and I have to put in a proxy to make outbound calls.
curl_setopt ($curl,CURLOPT_PROXY,'http://proxy.shr.secureserver.net:3128');
精彩评论