#1 Le 29/05/2007, à 23:40
- optar1
apostrophes et points dans parser RSS
Bonjour,
j'utilise readrss couplé à magpierss pour afficher des flux rss. Malheureusement, les apostrophes ne s'affichent pas (remplacés par un point d'interrogation), ainsi que trois petits points "..." , remplacés eux aussi par un point d'interrogation à l'affichage. Concernant les accents, tout va bien par contre.
Voici mon fichier readrss.php:
<?php header("Content-Type: text/html;charset=iso-8859-1");
require_once('magpierss/rss_fetch.inc');
define("MAGPIE_CACHE_AGE",600); // Cache time in seconds- 10 minutes
if(!isset($_GET['rssURL'])){
die("No RSS url given");
}
if(!file_exists("cache"))mkdir("cache",0775);
$rss = fetch_rss($_GET['rssURL']);
$rssItems = $rss->items; // News items
$maxRssItems = $_GET['maxRssItems']; // Maximum number of RSS news to show.
echo $rss->channel['title']."\n"; // Site title
echo min($maxRssItems,count($rssItems))."\n"; // Number of news
$outputItems = array(); // Creating new array - this items holds the data we send back to the client
for($no=0;$no<count($rssItems);$no++){
#if(!isset($rssItems[$no]["pubdate"]))$rssItems[$no]["pubdate"]=$no;
if(!isset($rssItems[$no]["description"]))$rssItems[$no]["description"]=" ";
$key = $rssItems[$no]["date_timestamp"].(5000 - $no);
$outputItems[$key] = array(
"title"=>$rssItems[$no]["title"],
"date_timestamp"=>$rssItems[$no]["date_timestamp"],
"pubdate"=>$rssItems[$no]["pubdate"],
"description"=>$rssItems[$no]["description"],
"link"=>$rssItems[$no]["link"],
"category"=>$rssItems[$no]["category"]);
}
ksort($outputItems,SORT_NUMERIC); // Sorting items from the key
$outputItems = array_reverse($outputItems); // Reverse array so that the newest item appear first
$countItems = 0;
foreach($outputItems as $key=>$value){ // Output items - looping throught the array $outputItems
echo "\n\n";
echo date("d/m/y",$value["date_timestamp"])." - ".preg_replace("/[\r\n]/"," ",$value["title"])."##"; // Title
echo date("d/m/y",$value["date_timestamp"])."##"; // Date
echo preg_replace("/[\r\n]/"," ",$value["description"])."##"; // Description
echo preg_replace("/[\r\n]/"," ",$value["link"])."##"; // Link
$countItems++;
if($countItems>=$maxRssItems)exit;
}
exit;
?>
ya t'il quelque chose à ajouter? (ps, merci de ne pas m'indiquer d'autres parser je tiens absolument à l'utiliser pour un script).
merci.
++
#2 Le 30/05/2007, à 08:35
- Tonio
Re : apostrophes et points dans parser RSS
Hello,
Pas un problème d'encodage ?
Dernière modification par Tonio (Le 30/05/2007, à 08:36)
Hors ligne