Error with SimplePie_Item extensions #377

Open
pethr opened this Issue Sep 13, 2014 · 0 comments

Projects

None yet

1 participant

@pethr
pethr commented Sep 13, 2014

SimplePie examples extending SimplePie_Item do not seem to work for me – f.e. http://simplepie.org/wiki/addons/digg

The first custom (prefixed) field causes "Fatal error: Call to a member function get_label() on a non-object in /Library/WebServer/Documents/simplepie_test3.php on line 26"

Any ideas how to fix this? Am I including the files wrong? Thanks for any help I have spent hours trying to make this work.

<?php
require_once ('/Library/WebServer/Documents/simplepie/autoloader.php');
require_once ('/Library/WebServer/Documents/simplepie/library/SimplePie/Item/Digg.php');

$feed = new SimplePie();
$feed->set_feed_url('http://digg.com/rss/index.xml');
$feed->set_item_class('SimplePie_Item_Digg');
$feed->init();
$feed->handle_content_type();

?><!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>Sample Page to test SimplePie add-on for Digg.com</title>
</head>

<body>
    <h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>

    <?php foreach($feed->get_items() as $item): ?>

    <h3><img src="<?php echo $item->get_submitter_image(); ?>" alt="<?php echo $item->get_submitter_username(); ?>" title="<?php echo $item->get_submitter_username(); ?>" width="16" height="16" /> <a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h3>
    <p><?php echo $item->get_description(); ?></p>
    <p><small>Diggs: <?php echo $item->get_digg_count(); ?> | Submitted by: <?php echo $item->get_submitter_username(); ?> | Comments: <?php echo $item->get_comment_count(); ?> | Category: <?php $category = $item->get_category(0); echo $category->get_label(); ?> | <?php echo $item->get_date('l, F jS Y, g:i a'); ?></small></p>
    <hr />

    <?php endforeach; ?>

</body>
</html>
'''
@pethr pethr changed the title from Fatal error with SimplePie_Item extensions to Error with SimplePie_Item extensions Sep 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment