Comment afficher les images d'un flux rss
Résolu
theliopro
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
bg62 Messages postés 23733 Date d'inscription Statut Modérateur Dernière intervention -
bg62 Messages postés 23733 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
Bonjour,
je suis entrain d'essayer de faire afficher un flux RSS sur ma page web.
J'arrive à afficher les liens avec leurs titres, descriptions et dates mais je n'arrive pas à afficher leurs images
Voici un exemple de ce que je veux faire: https://dupont-orthez.notaires.fr/
j'utilise le rsslib:
<? Php
/ *
RSS Extractor et Displayer
(C) 2007-2009 Scriptol.com - Licence Mozilla 1.1.
rsslib.php
Exigences:
- PHP 5.
- Un flux RSS.
Utilisation de la bibliothèque:
Insérez ce code dans la page qui affiche le flux RSS:
<? Php
require_once ("rsslib.php");
écho RSS_Display ("https://www.xul.fr/rss.xml", 15);
?>
* /
$ RSS_Content = array ();
RSS_Tags fonction ($ item, $ type)
{
$ Y = array ();
$ Tnl = $ item-> getElementsByTagName ("title");
$ Tnl = $ tnl-> item (0);
$ Title = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("link");
$ Tnl = $ tnl-> item (0);
$ Link = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("description");
$ Tnl = $ tnl-> item (0);
$ Description = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("image");
$ Tnl = $ tnl-> item (0);
$ Image = $ tnl-> firstChild-> data;
$ Tnl = $ item-> getElementsByTagName ("pubDate");
$ Tnl = $ tnl-> item (0);
$ Date = $ tnl-> firstChild-> textContent;
$ Date = date ("d / m / Y", strtotime ("$ date"));
$ Y ["titre"] = $ titre;
$ Y ["link"] = $ lien;
$ Y ["description"] = $ description;
$ Y ["image"] = $ image;
$ Y ["date"] = $ date;
$ Y ["type"] = $ type;
return $ y;
}
RSS_Channel fonction ($ channel)
{
global $ RSS_Content;
$ Articles = $ channel-> getElementsByTagName ("item");
/ / Traitement du canal
$ Y = $ (RSS_Tags canal, 0); / / obtenir la description du canal, tapez 0
array_push ($ RSS_Content, $ y);
/ / Traitement des articles
foreach ($ items as $ item)
{
$ Y = RSS_Tags ($ item, 1); / / obtenir une description de l'article, de type 1
array_push ($ RSS_Content, $ y);
}
}
fonction RSS_Retrieve ($ url)
{
global $ RSS_Content;
$ Doc = new DOMDocument ();
$ Doc-> load ($ url);
$ De canaux = $ doc-> getElementsByTagName ("channel");
$ RSS_Content = array ();
foreach ($ canaux comme le canal $)
{
RSS_Channel ($ channel);
}
}
RSS_RetrieveLinks function ($ url)
{
global $ RSS_Content;
$ Doc = new DOMDocument ();
$ Doc-> load ($ url);
$ De canaux = $ doc-> getElementsByTagName ("channel");
$ RSS_Content = array ();
foreach ($ canaux comme le canal $)
{
$ Articles = $ channel-> getElementsByTagName ("item");
foreach ($ items as $ item)
{
$ Y = RSS_Tags ($ item, 1); / / obtenir une description de l'article, de type 1
array_push ($ RSS_Content, $ y);
}
}
}
RSS_Links function ($ url, $ size = 15)
{
global $ RSS_Content;
$ Page = "<ul>";
RSS_RetrieveLinks ($ url);
if ($ taille> 0)
$ Recents = array_slice ($ RSS_Content, 0, $ taille + 1);
foreach ($ recents as $ article)
{
$ Type = $ article ["type"];
if ($ type == 0) continue;
$ Title = $ article ["titre"];
$ Link = $ article ["link"];
$ Page = "<a <li> target=\"_blank\" href=\"$link\"> $ titre </ a> </ li> \ n".;
}
$ Page = "</ ul> \ n".;
return $ page;
}
RSS_Display fonction ($ url, $ size = 15, $ site = 0)
{
global $ RSS_Content;
$ A ouvert = false;
$ Page = "";
$ Site = (intval ($ site) == 0)? 1: 0;
RSS_Retrieve ($ url);
if ($ taille> 0)
$ Recents = array_slice ($ RSS_Content, $ site, $ taille + 1 - $ site);
foreach ($ recents as $ article)
{
$ Type = $ article ["type"];
if ($ type == 0)
{
if ($ a ouvert == true)
{
$ Page = "</ ul> \ n".;
$ A ouvert = false;
}
$ Page = "<b>".;
}
d'autre
{
if ($ a ouvert == false)
{
$ Page = "<ul> \ n".;
$ A ouvert = true;
}
}
$ Title = $ article ["titre"];
$ Link = $ article ["link"];
$ Description = $ article ["description"];
$ Image = $ article ['«image»];
$ Page = "<a <li> target=\"_blank\" href=\"$link\"> $ title <img src=\"$image\" /> </ a>";. / * ". $ article ['date']. "* /
if ($ description! = false)
{
$ Page = "description de <br> $ <br>".;
$ Page = $ article ['date'].;
}
$ Page = "</ li> \ n".;
if ($ type == 0)
{
$ Page = "</ b> <br />".;
}
}
if ($ a ouvert == true)
{
$ Page = "</ ul> \ n".;
}
return $ page "\ n".;
}
?>
la page qui appelle le rsslib est la suivante:
<DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Page de test with <title> flux rss </ title>
</ Head>
<body bgcolor="#FFFFFF">
<h1> RSS 2.0 Direct Démo </ h1>
<hr>
<div id="zone"> Chargeur Directement non flux RSS et la liste le Display articles Des Récents. </ div>
<br>
<fieldset class="rsslib">
<? Php
require_once ("rsslib.php");
$ Url = "https://www.notaires.fr/fr/rss";
echo RSS_Display ($ url, 15, false, true);
?>
</ Fieldset>
</ Body>
</ Html>
BESOIN D'AIDE MERCI!!!!!!!!!!!
Bonjour,
je suis entrain d'essayer de faire afficher un flux RSS sur ma page web.
J'arrive à afficher les liens avec leurs titres, descriptions et dates mais je n'arrive pas à afficher leurs images
Voici un exemple de ce que je veux faire: https://dupont-orthez.notaires.fr/
j'utilise le rsslib:
<? Php
/ *
RSS Extractor et Displayer
(C) 2007-2009 Scriptol.com - Licence Mozilla 1.1.
rsslib.php
Exigences:
- PHP 5.
- Un flux RSS.
Utilisation de la bibliothèque:
Insérez ce code dans la page qui affiche le flux RSS:
<? Php
require_once ("rsslib.php");
écho RSS_Display ("https://www.xul.fr/rss.xml", 15);
?>
* /
$ RSS_Content = array ();
RSS_Tags fonction ($ item, $ type)
{
$ Y = array ();
$ Tnl = $ item-> getElementsByTagName ("title");
$ Tnl = $ tnl-> item (0);
$ Title = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("link");
$ Tnl = $ tnl-> item (0);
$ Link = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("description");
$ Tnl = $ tnl-> item (0);
$ Description = $ tnl-> firstChild-> textContent;
$ Tnl = $ item-> getElementsByTagName ("image");
$ Tnl = $ tnl-> item (0);
$ Image = $ tnl-> firstChild-> data;
$ Tnl = $ item-> getElementsByTagName ("pubDate");
$ Tnl = $ tnl-> item (0);
$ Date = $ tnl-> firstChild-> textContent;
$ Date = date ("d / m / Y", strtotime ("$ date"));
$ Y ["titre"] = $ titre;
$ Y ["link"] = $ lien;
$ Y ["description"] = $ description;
$ Y ["image"] = $ image;
$ Y ["date"] = $ date;
$ Y ["type"] = $ type;
return $ y;
}
RSS_Channel fonction ($ channel)
{
global $ RSS_Content;
$ Articles = $ channel-> getElementsByTagName ("item");
/ / Traitement du canal
$ Y = $ (RSS_Tags canal, 0); / / obtenir la description du canal, tapez 0
array_push ($ RSS_Content, $ y);
/ / Traitement des articles
foreach ($ items as $ item)
{
$ Y = RSS_Tags ($ item, 1); / / obtenir une description de l'article, de type 1
array_push ($ RSS_Content, $ y);
}
}
fonction RSS_Retrieve ($ url)
{
global $ RSS_Content;
$ Doc = new DOMDocument ();
$ Doc-> load ($ url);
$ De canaux = $ doc-> getElementsByTagName ("channel");
$ RSS_Content = array ();
foreach ($ canaux comme le canal $)
{
RSS_Channel ($ channel);
}
}
RSS_RetrieveLinks function ($ url)
{
global $ RSS_Content;
$ Doc = new DOMDocument ();
$ Doc-> load ($ url);
$ De canaux = $ doc-> getElementsByTagName ("channel");
$ RSS_Content = array ();
foreach ($ canaux comme le canal $)
{
$ Articles = $ channel-> getElementsByTagName ("item");
foreach ($ items as $ item)
{
$ Y = RSS_Tags ($ item, 1); / / obtenir une description de l'article, de type 1
array_push ($ RSS_Content, $ y);
}
}
}
RSS_Links function ($ url, $ size = 15)
{
global $ RSS_Content;
$ Page = "<ul>";
RSS_RetrieveLinks ($ url);
if ($ taille> 0)
$ Recents = array_slice ($ RSS_Content, 0, $ taille + 1);
foreach ($ recents as $ article)
{
$ Type = $ article ["type"];
if ($ type == 0) continue;
$ Title = $ article ["titre"];
$ Link = $ article ["link"];
$ Page = "<a <li> target=\"_blank\" href=\"$link\"> $ titre </ a> </ li> \ n".;
}
$ Page = "</ ul> \ n".;
return $ page;
}
RSS_Display fonction ($ url, $ size = 15, $ site = 0)
{
global $ RSS_Content;
$ A ouvert = false;
$ Page = "";
$ Site = (intval ($ site) == 0)? 1: 0;
RSS_Retrieve ($ url);
if ($ taille> 0)
$ Recents = array_slice ($ RSS_Content, $ site, $ taille + 1 - $ site);
foreach ($ recents as $ article)
{
$ Type = $ article ["type"];
if ($ type == 0)
{
if ($ a ouvert == true)
{
$ Page = "</ ul> \ n".;
$ A ouvert = false;
}
$ Page = "<b>".;
}
d'autre
{
if ($ a ouvert == false)
{
$ Page = "<ul> \ n".;
$ A ouvert = true;
}
}
$ Title = $ article ["titre"];
$ Link = $ article ["link"];
$ Description = $ article ["description"];
$ Image = $ article ['«image»];
$ Page = "<a <li> target=\"_blank\" href=\"$link\"> $ title <img src=\"$image\" /> </ a>";. / * ". $ article ['date']. "* /
if ($ description! = false)
{
$ Page = "description de <br> $ <br>".;
$ Page = $ article ['date'].;
}
$ Page = "</ li> \ n".;
if ($ type == 0)
{
$ Page = "</ b> <br />".;
}
}
if ($ a ouvert == true)
{
$ Page = "</ ul> \ n".;
}
return $ page "\ n".;
}
?>
la page qui appelle le rsslib est la suivante:
<DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Page de test with <title> flux rss </ title>
</ Head>
<body bgcolor="#FFFFFF">
<h1> RSS 2.0 Direct Démo </ h1>
<hr>
<div id="zone"> Chargeur Directement non flux RSS et la liste le Display articles Des Récents. </ div>
<br>
<fieldset class="rsslib">
<? Php
require_once ("rsslib.php");
$ Url = "https://www.notaires.fr/fr/rss";
echo RSS_Display ($ url, 15, false, true);
?>
</ Fieldset>
</ Body>
</ Html>
BESOIN D'AIDE MERCI!!!!!!!!!!!
A voir également:
- Comment afficher les images d'un flux rss
- Afficher appdata - Guide
- Des images - Guide
- Extraire les images d'un pdf - Guide
- Faites afficher avec un fond coloré les cellules qui contiennent une valeur comprise entre 250 et 350. quel nombre est dessiné en surbrillance ? ✓ - Forum Excel
- Afficher les commentaires word - Guide
3 réponses
C'est bon j'ai trouvé tout seul comme un grand :D
MERCI à moi tout seul !!!!!!!!!
// Nous voici au coeur du code d'intégration. for($x=0; $x<$max; $x++) { // On prend le x-ième item. $item=$feed->get_item($x); // Un peu d'habillage html. echo "<div style=\"width: 290px; text-align: left; padding: 4px; background-color: #FFFFEE; border: 1px solid #CCCCCC; margin: 6px;\"> <a href=\""; // le lien ou pointe le flux. echo $item->get_permalink(); echo "\">"; // le titre du flux. echo $item->get_title(); echo "</a><br />"; // si enclosure, on affiche l'image. if($enclosure=$item->get_enclosure(0)){ echo "<img src=\""; echo $enclosure->get_link(); echo "\" border=\"1\" style=\"float: left; margin: 4px; margin-top: 8px; width: 265px; \">"; } // On affiche la description et la date pour finir. echo $item->get_description(); echo '<br/>'; echo $item->get_date('j M Y'); echo "</div>"; }
MERCI à moi tout seul !!!!!!!!!
bg62
Messages postés
23733
Date d'inscription
Statut
Modérateur
Dernière intervention
2 409
ne pas oublier qu'il faut un dossier cache pour l'écriture ... :)
je rêve là ... ?
pourquoi ça alors qu'il s'agit d'un site quasiment statique et qui n'a même pas de NDD (... en passant : 1 post et hop j'essaie de caser un lien ....!) , ça ne servira absolument à rien ...
:)
pourquoi ça alors qu'il s'agit d'un site quasiment statique et qui n'a même pas de NDD (... en passant : 1 post et hop j'essaie de caser un lien ....!) , ça ne servira absolument à rien ...
:)
Ok bg62 je comprends pas ce que tu essaie de me dire !! Après plusieurs recherche j'ai découvert que c'est plus simple d'utiliser simplepie pour afficher les flux sur son sie web !!
et j'ai cette partie de code la pour afficher les info du flux :
je voudrais savoir quoi ecrir dans le echo du if ($enclosure = $item->get_enclosure()) pour pouvoir afficher l'image !!
merciii
et j'ai cette partie de code la pour afficher les info du flux :
<div class="item"> <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2> <p><?php echo $item->get_description(); ?></p> <p><small>Posté le <?php echo $item->get_date('j M Y'); ?></small></p> <?php if ($enclosure = $item->get_enclosure()) { echo '<img src="" alt="" />'; } ?> </div>
je voudrais savoir quoi ecrir dans le echo du if ($enclosure = $item->get_enclosure()) pour pouvoir afficher l'image !!
merciii