Bonjour,
je suis a la recherche d'un script, ou bon tutoriaux sur la syndication.
Si kel kun peut m'aider.
Merci
<?php
$headline_style='';
$description_style='';
$feed_url='';
$show_detail=false;
$insideitem=false;
$tag="";
$title="";
$description="";
$link="";
$image="";
$insideimage=false;
$max=3; // nombre maximum de news afficher par page
$count=0;
function render_news($feed_url, $showdetail, $headlinestyle,$detailstyle)
{
global $show_detail, $headline_style, $detail_style, $max, $count, $insideitem, $insideimage;
$insideitem = false;
$insideimage = false;
$count = 0;
$show_detail = $showdetail;
$headline_style = $headlinestyle;
$detail_style = $detailstyle;
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser,"startElement", "endElement");
xml_set_character_data_handler($xml_parser,"characterData");
$fp = @fopen($feed_url, "r") or die("Erreur à la lecture du fichier RSS.");
if($fp)
{
while($data = fread($fp,4096))
xml_parse($xml_parser, $data, feof($fp)) or die(sprintf("Erreur XML n° %s à la ligne %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
}
else
{
echo'<span class="'.$detail_style.'">Contenu inacessible</span>';
}
xml_parser_free($xml_parser);
}
function startElement($parser, $name, $attrs)
{
global $insideitem, $tag, $title, $description, $link, $image, $insideimage;
if($insideitem || $insideimage)
{
$tag = $name;
}
if($name == "ITEM")
{
$insideitem = true;
}
if($name == "IMAGE")
{
$insideimage = true;
}
}
function endElement($parser, $name)
{
global $insideitem, $tag, $title, $description, $link, $image, $insideimage,
$show_detail, $headline_style, $detail_style, $count, $max;
if($name == "URL")
{
echo'<img src = "'.htmlspecialchars(trim($image)).'"/><br><br>';
$insideimage = false;
$image="";
}
else if($name == "ITEM" && $count < $max)
{
$count++;
printf('<a href="%s" class="'.$headline_style.'" target="_blank"> <b>%s</b></a><br>',
trim($link), trim(htmlspecialchars($title)));
if($show_detail)
printf('<span class="'.$detail_style.'">%s</span><br>',
trim(htmlspecialchars($description)));
else{echo"<br>";}
$title="";
$description="";
$link="";
$insideitem=false;
}
}
function characterData($parser, $data)
{
global $insideitem, $tag, $title, $description, $link, $image, $insideimage;
if($insideimage)
{
switch($tag)
{
case "URL":
$image.=$data;
break;
}
}
if($insideitem)
{
switch($tag)
{
case "TITLE": $title.=$data;
break;
case "DESCRIPTION": $description.=$data;
break;
case "LINK";
$link.=$data;
break;
}
}
}
render_news("http://www.journaldelagence.com/backend.php",true,'news','news'); //chemin du site syndicalisé
?>