Wednesday, 15 September 2010

php - simplexml-load-file : failed to open stream: Redirection limit reached -



php - simplexml-load-file : failed to open stream: Redirection limit reached -

i trying open xml file these errors :

warning: simplexml_load_file(http://www.bva.fr/fr/rss/sondages.xml) [function.simplexml-load-file]: failed open stream: redirection limit reached, aborting in /xxx/import.php on line 93 warning: simplexml_load_file() [function.simplexml-load-file]: i/o warning : failed load external entity "http://www.bva.fr/fr/rss/sondages.xml" in /xxx/import.php on line 93 notice: trying property of non-object in /xxx/import.php on line 99 warning: invalid argument supplied foreach() in /xxx/import.php on line 99

line 99 :

foreach($xml->channel->item $item)

i tried :

$xml = simplexml_load_file($url);

and :

$curl = curl_init(); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_followlocation, true); $content = curl_exec($curl); curl_close($curl); $xml = simplexml_load_string($content);

but still doesn't work...

here xml file : http://www.bva.fr/fr/rss/sondages.xml

could please help me ?

you maybe seek add together complementary curl options : here finish illustration ok rss site.

$options = array( curlopt_returntransfer => true, // homecoming web page curlopt_header => false, // don't homecoming headers curlopt_followlocation => true, // follow redirects curlopt_encoding => "", // handle encodings curlopt_useragent => "mozilla/5.0 (windows nt 6.1; wow64; rv:18.0) gecko/20100101 firefox/18.0", // firefox curlopt_autoreferer => true, // set referer on redirect curlopt_connecttimeout => 120, // timeout on connect curlopt_timeout => 120, // timeout on response curlopt_maxredirs => 10, // stop after 10 redirects );

replace curl_setopt($curl, curlopt_url, $url); curl_setopt_array( $curl, $options ); in example.

php curl simplexml

No comments:

Post a Comment