Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rss-Feed einbinden
#5
So, nach meinem kleinen Urlaub habe ich mich nochmal an den rss-feed gemacht.

Erstmal Danke Lars, für deine ersten Hilfen!

Habe bei der Recherche gelesen, dass dafür ein Parser notwendig wäre? Ich hab mir dann mal Simplepie (www.simplepie.org) geholt und die Dokumentation dazu sowie einige Tutorials angeschaut, aber dennoch bekomme ich keinen rss-feed zum laufen  Huh  Hab natürlich mal tesweise andere versucht, so zum Beispiel http://www.spiegel.de/panorama/index.rss .

Außer einem Querstrich wird mir von der index.php nichts angezeigt. Ich poste im Anschluss mal den code, auch wenn das ja jetzt nicht wirklich viel mit getsimple zu tun hat...

Viele Grüße!


PHP Code:
<?php
 
// Make sure SimplePie is included. You may need to change this to match the location of autoloader.php
// For 1.0-1.2:
#require_once('../simplepie.inc');
// For 1.3+:
require_once('simplepie/autoloader.php');
 
// We'll process this feed with all of the default options.
$feed = new SimplePie();
 
// Set the feed to process.
$feed->set_feed_url('http://www.spiegel.de/panorama/index.rss');
 
// Run SimplePie.
$feed->init();
 
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
 
// Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 
 
<html xmlns="
<head>
    <title>Sample SimplePie Page</title>
 
 
    <style type="text/css">
    body {
        font:12px/1.4em Verdana, sans-serif;
        color:#333;
        background-color:#fff;
        width:700px;
        margin:50px auto;
        padding:0;
    }
 
    a {
        color:#326EA1;
        text-decoration:underline;
        padding:0 1px;
    }
 
    a:hover {
        background-color:#333;
        color:#fff;
        text-decoration:none;
    }
 
    div.header {
        border-bottom:1px solid #999;
    }
 
    div.item {
        padding:5px 0;
        border-bottom:1px solid #999;
    }
    </style>
 
</head>
<body>
 
    <div class="header">
        <h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
        <p><?php echo $feed->get_description(); ?></p>
    </div>
 
    <?php
    
/*
    Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop.
    */
    
foreach ($feed->get_items() as $item):
    
?>
 
        <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>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
        </div>
 
    <?php endforeach; ?>
 
</body>
</html> 
Reply


Messages In This Thread
rss-Feed einbinden - by stwneu - 2015-04-28, 22:02:16
RE: rss-Feed einbinden - by Lars - 2015-04-28, 23:06:22
RE: rss-Feed einbinden - by stwneu - 2015-04-29, 18:49:37
RE: rss-Feed einbinden - by Lars - 2015-04-29, 19:18:39
RE: rss-Feed einbinden - by stwneu - 2015-05-06, 17:55:23
RE: rss-Feed einbinden - by Lars - 2015-05-06, 19:03:46



Users browsing this thread: 1 Guest(s)