Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/07/2008, 13h17   #1
Futur Membre du Club
 
Inscription : août 2006
Messages : 82
Détails du profil
Informations forums :
Inscription : août 2006
Messages : 82
Points : 15
Points : 15
Par défaut Erreur PHP avec SimplePie

Bonjour,

j'utilise la dernière version de simplepie comme cela:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
<?php
require_once('./pie/simplepie.inc');
 
$flux1 = new SimplePie();
$flux1->set_feed_url('http://feeds.feedburner.com/Aful-CommuniqusDePresseEtNouvelles');
$flux1->set_item_limit(10);
$flux1->set_cache_duration(999999);
$flux1->init();
 
$flux2 = new SimplePie();
$flux2->set_feed_url('http://www.april.org/serveur/april.xml');
$flux2->set_item_limit(5);
$flux2->set_cache_duration(999999);
$flux2->init();
 
// Let's merge them together.
$merged = SimplePie::merge_items(array($flux1, $flux2));
header('Content-type:text/html; charset=utf-8');
?>
et le code dans le <body> est:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
<div id="site">
<h1>Awesome feeds</h1>
<?php
// Instead of calling $feed->get_items(), we'll use the $merged variable we created earlier.
foreach ($merged as $item):
?>
 
<div class="chunk">
<?php /* Here, we'll use the $item->get_feed() method to gain access to the parent feed-level data for the specified item. */ ?>
<h4 class="title" style="background-image:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>);"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>
<?php echo $item->get_content(); ?>
<p class="footnote">Source: <a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>
</div>
 
<?php endforeach; ?>
</div>
Et donc j'ai cette erreur:
Code :
Warning: Invalid argument supplied for foreach() in /home/toto/website/index.php on line 801
Qui correspond à cette ligne:
Code :
foreach ($merged as $item):
Quel est le problème?

++
csseur22 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/07/2008, 13h25   #2
Rédacteur
 
Avatar de Yoteco
 
Alain Sahli
Ingénieur développement logiciels
Inscription : décembre 2004
Messages : 1 086
Détails du profil
Informations personnelles :
Nom : Alain Sahli
Âge : 25

Informations professionnelles :
Activité : Ingénieur développement logiciels
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : décembre 2004
Messages : 1 086
Points : 1 479
Points : 1 479
Salut,

Si on lit bêtement l'erreur que tu obtiens, l'argument que tu passes au foreach n'est pas correct. Est-ce qu'on peut voir un peu plus en détail le code avant ton foreach ?
Yoteco est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h44.


 
 
 
 
Partenaires

Hébergement Web