1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <?php
/********************************************************************
MULTIFEEDS TEST PAGE
Nothing too exciting here. Just a sample page that demos integrated
Multifeeds support as well as cached favicons and perhaps a few other
things.
Lots of this code is commented to help explain some of the new stuff.
Code was tested in PHP 5.2.2, but *should* also work with earlier
versions of PHP, as supported by SimplePie (PHP 4.1).
********************************************************************/
// Include the SimplePie library, and the one that handles internationalized domain names.
require_once('../simplepie.inc');
require_once('../idn/idna_convert.class.php');
// Initialize some feeds for use.
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://www.planete-mars.net/mylastrss/examples/merge-to-one-feed/'
));
// When we set these, we need to make sure that the handler_image.php file is also trying to read from the same cache directory that we are.
// $feed->set_favicon_handler('handler_image.php');
$feed->set_image_handler('handler_image.php');
// Initialize the feed.
$feed->init();
// Make sure the page is being served with the UTF-8 headers.
$feed->handle_content_type();
// Begin the (X)HTML page.
?><!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" xml:lang="en" lang="en">
<head>
<title>Revue de presse OM</title>
<link rel="stylesheet" href="../demo/for_the_demo/simplepie.css" type="text/css" media="screen" title="SimplePie Styles" />
<style type="text/css">
div#site {
width:310px;
}
</style>
</head>
<body>
<div id="site">
<?php if ($feed->error): ?>
<p><?=$feed->error()?></p>
<?php endif ?>
<?php
// Let's loop through each item in the feed.
foreach($feed->get_items() as $item):
// Let's give ourselves a reference to the parent $feed object for this particular item.
$feed = $item->get_feed();
?>
<div class="chunk">
<h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'ISO-8859-1'); ?></a></h4>
<?php
if($enclosure=$item->get_enclosure(0)){
echo "<img src=\"";
echo $enclosure->get_link();
echo "\" border=\"1\" style=\"float: left; margin: 4px; max-height:80px; max-width:100px; margin-top: 8px;\">";
}
?>
<!-- get_content() prefers full content over summaries -->
<?php
echo $item->get_description();
echo $item->get_date('j M Y | G:i ');
?>
</div>
<?php endforeach ?>
</div>
</body>
</html> |
Partager