[spip-dev] Double header Warning error 2.1

Salut,

Je travail sur un petit plugins afin d’afficher la météo avec l’api gogole !

Le plugins fonctionne en 2.1, cependant je recontre un message d’erreur.

kent1 m’à précisé que ce serait peut être à cause de ecrire/inc/distant.php

function recuperer_page($url, $trans=false, $get_headers=false,

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Warning: Cannot modify header information - headers already sent by (output started at /var/www/spip/SPIP-branche-2.1/plugins/Meteoogle/meteoogle_fonctions.php:17) in /var/www/spip/SPIP-branche-2.1/ecrire/inc/actions.php on line 213
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mon fichier contenant le premier header fautif :

<?php function meteOogle() { $requestAddress = "[http://www.google.com/ig/api?weather='.$_POST[codeville].'&hl=en](http://www.google.com/ig/api?weather='.$_POST[codeville].'&hl=en)"; $xml_str = file_get_contents($requestAddress,0); // Parses XML $xml = new SimplexmlElement($xml_str); // Loops XML $count = 0; echo <forecast_conditions[0]->city['data']; //var_dump($xml); echo '
'; foreach($xml->weather as $item) { foreach($item->forecast_conditions as $new) { echo '
'; echo '
'; echo $new->day_of_week['data']; echo '
'; } echo $item->forecast_information->city['data']; echo $item->condition['data']; } echo '
'; } // on appel meteOogle(); ?>

Salut,

Je travail sur un petit plugins afin d’afficher la météo avec l’api gogole !

Le plugins fonctionne en 2.1, cependant je recontre un message d’erreur.

kent1 m’à précisé que ce serait peut être à cause de ecrire/inc/distant.php

function recuperer_page($url, $trans=false, $get_headers=false,

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Warning: Cannot modify header information - headers already sent by (output started at /var/www/spip/SPIP-branche-2.1/plugins/Meteoogle/meteoogle_fonctions.php:17) in /var/www/spip/SPIP-branche-2.1/ecrire/inc/actions.php on line 213
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mon fichier contenant le premier header fautif :

<?php function meteOogle() { $requestAddress = "[http://www.google.com/ig/api?weather='.$_POST[codeville].'&hl=en](http://www.google.com/ig/api?weather='.$_POST[codeville].'&hl=en)"; $xml_str = file_get_contents($requestAddress,0); // Parses XML $xml = new SimplexmlElement($xml_str); // Loops XML $count = 0; echo <<< END

echo provoque un affichage et donc l’envoi des headers

headers already sent by (output started at /var/www/spip/SPIP-branche-2.1/plugins/Meteoogle/meteoogle_fonctions.php:17)

je ne sais pas comment tu appelle ta fonction mais il NE FAUT PAS faire echo dedans.

Si tu l’appelles comme un filtre, il faut simplement faire un return $xxx;
le contenu en sera affiché dans le squelette

Cédric