Results 1 to 6 of 6

Thread: rssdisplaybox Fatal error: Call to a member function set_feed_url()

  1. #1
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Question rssdisplaybox Fatal error: Call to a member function set_feed_url()

    1) Script Title:
    rssdisplaybox

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...rssdisplaybox/

    3) Describe problem:

    I kept getting location of cache folder errors
    now the local errors are
    PHP Fatal error: Call to a member function get_permalink() on a non-object in outputbody.php on line 11
    the online errors
    rssdisplaybox
    or
    demo

    Fatal error: Call to a member function set_feed_url() on null in
    Any ideas or fix? please
    Last edited by student101; 06-16-2018 at 05:30 PM. Reason: resolved!
    ASCII stupid question, get a stupid ANSI!
    Beta is Latin for still doesn’t work.
    Mac users swear by their Mac, PC users swear at their PC.
    Keyboard not found...Press any key to continue.

  2. #2
    Join Date
    Jan 2015
    Posts
    76
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Default

    The first (local) error is because $item is a value but it isn't an object. The next (online) errors are because $feed is a null value. Posting your custom outputbody.php and main.php code and what version of SimplePie would help.

    These errors are related to the SimplePie php statements. It would take someone familiar with SimplePie to directly help (I stopped looking at the code after scrolling through the 2nd 3000+ line file.) You could ask on the SimplePie support forum.

    I did see that the code is using indirect (variable) referencing. This is one of the things that changed in php7. What version of php are you using on the online system, as this code may need to be updated to run under php7, so that it returns the correct values to the calling code?

    Edit: and since you are getting different errors on your local and online systems, what php version are you using on your local system?

  3. The Following User Says Thank You to DyDr For This Useful Post:

    student101 (06-16-2018)

  4. #3
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    Thanks for your reply!

    Online
    PHP 5.6.36

    Local with XAMPP
    PHP 5.4.19


    ************************************************************
    - Dynamic Drive note: This version of SimplePie contained inside rssdisplaybox.zip is 1.0 beta3.2, downloaded Dec 2nd, 2006
    - /demo/ directory removed from default package
    - SimplePie site: http://simplepie.org
    ************************************************************

    original rssdisplaybox with simplepie.inc

    Deprecated: Non-static method SimplePie_Misc::fix_protocol() should not be called statically, assuming $this from incompatible context in
    main.php
    Code:
    <?php
    //Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com
    
    require('../simplepie/simplepie.inc'); //Specify path to simplepie.inc on your server (by default located inside "simplepie" directory)
    $feed = new SimplePie();
    $feed->cache_location('cache'); //Specify path to cache directory on your server relative to this file
    $feed->handle_content_type();
    require('outputbody.php'); //Path to custom "outputbody.php" file relative to this file
    
    //Specify list of RSS URLs
    $rsslist=array(
    "cssdrive" => "http://www.cssdrive.com/index.php/news/rss_2.0/",
    "bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
    "nytimes" => "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
    "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new" //no trailing comma after last RSS URL!!
    );
    
    ////Beginners don't need to configure past here. Edit outputbody.php to format the output of each RSS item's body ////////////////////
    
    $rssid=$_GET['id'];
    $rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("<b>Error:</b> Can't find requested RSS in list.");
    $cachetime=isset($_GET["cachetime"])? (int)$_GET["cachetime"] : 30; //Get cachetime. Default to 30 if not specified
    $feednumber=isset($_GET["limit"])? (int)$_GET["limit"] : ""; //Get number of items to fetch. If not specified (""), all is fetched.
    
    $templatename=isset($_GET["template"])? $_GET["template"] : ""; //get name of template, which is used by if/else logic within function outputbody()
    if ($templatename!="" && !preg_match("/^(\w|-)+$/i", $templatename)) //Template name can only contain alphanumeric characters, underscore or dash (-)
    die ("<b>Error:</b> Template name can only consist of alphanumeric characters, underscore or dash");
    
    $feed->cache_max_minutes($cachetime);
    $feed->feed_url($rssurl);
    $feed->init();
    $max = $feed->get_item_quantity($feednumber);
    
    
    function outputitems(){
    global $feed, $feednumber, $templatename;
    $max = $feed->get_item_quantity($feednumber);
    for ($x = 0; $x < $max; $x++){
    $item = $feed->get_item($x);
    outputbody($item, $templatename); //call custom outputbody() function
    }
    }
    
    ?>
    <?php
    if ($feed->data){
    outputitems();
    }
    ?>
    Error: Can't find requested RSS in list.
    outputbody.php
    Code:
    <?
    //Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com
    //For syntax pf bpdu, see: http://simplepie.org/docs/installation/from-scratch/ and http://simplepie.org/docs/reference/
    //Function by default defines 3 different body outputs (templates). Modify or add additional templates as desired
    
    
    function outputbody($item, $template=""){
    if ($template=="" || $template=="default"){ //DEFAULT TEMPLATE
    	?>
    	<DIV class="rsscontainer">
    	<div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></div>
    	<div class="rssdate"><?php echo $item->get_date('d M Y g:i a'); ?></div>
    	<div class="rssdescription"><?php echo $item->get_description(); ?></div>
    	</DIV>
    	<?
    } //end default template
    else if ($template=="titles"){ //"TITLES" TEMPLATE
    	?>
    	<DIV class="rsscontainer">
    	<div class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>" target="_new"><?php echo $item->get_title(); ?></a></div> 
    	<div>Category: <?php echo $item->get_category(); ?></div>
    	</DIV>
    	<?
    } //end titles template
    else if ($template=="titlesdates"){ //"TITLESDATES" TEMPLATE
    	?>
    	<DIV class="rsscontainer">
    	<span class="rsstitle"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></span> 
    	<span class="rssdate"><?php echo $item->get_date('m/d/y g:i a'); ?></span>
    	</DIV>
    	<?
    } //end titlesdates template
    else if ($template=="mytemplatename"){ //"mytemplatename" TEMPLATE
    	?>
    	//DEFINE ADDITIONAL CUSTOM TEMPLATE(s) USING SAME LOGIC STRUCTURE AS ABOVE
    	//For syntax of template body, see SimplePie docs: http://simplepie.org/docs/installation/from-scratch/ and http://simplepie.org/docs/reference/
    	<?
    }
    
    
    
    
    else
    die ("No template exists with such name!");
    } //Closing function bracket
    ?>
    Blank page


    rssdisplaybox with autoloader.php

    rssdisplaybox with orginal simplepie 1.5 with autoloader.php
    main.php
    Code:
    <?php
    //Function for ouputting the body of each RSS item displayed (inside loop)- DynamicDrive.com
    
    require('../simplepie/autoloader.php'); //Specify path to simplepie.inc on your server (by default located inside "simplepie" directory)
    $feed = new SimplePie();
    $feed->enable_cache(false); //Specify caching true/false (unquoted)
    $feed->set_cache_location('../../cache');
    //$feed->cache_location('cache'); //Specify path to cache directory on your server relative to this file
    $feed->handle_content_type();
    require('outputbody.php'); //Path to custom "outputbody.php" file relative to this file
    
    /*$rsslist->set_feed_url('http://simplepie.org/blog/feed/');*/
    
    $rsslist->set_feed_url(array(
    "cssdrive" => "http://www.cssdrive.com/index.php/news/rss_2.0/",
    "bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
    "nytimes" => "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
    "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new" //no trailing comma after last RSS URL!!
    ));
    
    $feed->set_feed_url(array(
    "cssdrive" => "http://www.cssdrive.com/index.php/news/rss_2.0/",
    "bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
    "nytimes" => "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
    "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new" //no trailing comma after last RSS URL!!
    ));
    
    ////Beginners don't need to configure past here. Edit outputbody.php to format the output of each RSS item's body ////////////////////
    
    $rssid=$_GET['id'];
    $rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("<b>Error:</b> Can't find requested RSS in list.");
    $cachetime=isset($_GET["cachetime"])? (int)$_GET["cachetime"] : 30; //Get cachetime. Default to 30 if not specified
    $feednumber=isset($_GET["limit"])? (int)$_GET["limit"] : ""; //Get number of items to fetch. If not specified (""), all is fetched.
    
    $templatename=isset($_GET["template"])? $_GET["template"] : ""; //get name of template, which is used by if/else logic within function outputbody()
    if ($templatename!="" && !preg_match("/^(\w|-)+$/i", $templatename)) //Template name can only contain alphanumeric characters, underscore or dash (-)
    die ("<b>Error:</b> Template name can only consist of alphanumeric characters, underscore or dash");
    
    $feed->cache_max_minutes($cachetime);
    $feed->feed_url($rssurl);
    $feed->init();
    $max = $feed->get_item_quantity($feednumber);
    
    
    function outputitems(){
    global $feed, $feednumber, $templatename;
    $max = $feed->get_item_quantity($feednumber);
    for ($x = 0; $x < $max; $x++){
    $item = $feed->get_item($x);
    outputbody($item, $templatename); //call custom outputbody() function
    }
    }
    
    ?>
    
    <?php
    if ($feed->data){
    outputitems();
    }
    ?>
    Fatal error: Call to a member function set_feed_url() on null in main.php on line 14
    outputbody.php
    Code:
    same as outputbody.php
    Blank page
    Last edited by student101; 06-16-2018 at 07:12 AM.

  5. #4
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    installing new xampp with php 7 to test
    Last edited by student101; 06-16-2018 at 07:13 AM.

  6. #5
    Join Date
    Jan 2015
    Posts
    76
    Thanks
    0
    Thanked 18 Times in 18 Posts

    Default

    For the code using the latest SimplePie version, this is nonsense logic.

    $feed is the instance of SimplePie. You would call the SimplePie methods using $feed->method_name_here...()

    $rsslist should be an array of the rss feed ids and urls, like in the 1st code. The rest of the code should get the appropriate URL from the $rsslist array and call the SimplePie methods with that URL.

    AFAIK, to convert the 1st code to use the latest SimplePie, after you make the autoloader change, you should only need to change the names of the SimplePie methods that are being called. I don't specifically know what these are, but I did see a list of old/new names on the SimplePie web site. The logic being used in the 1st code, related to $feed and $rsslist should remain the same.

    Edit: The blank page may be due to the errors occurring in the code, but could be due to the short opening php tags - <? You should always use full opening php tags - <?php
    Last edited by DyDr; 06-15-2018 at 05:02 PM.

  7. The Following User Says Thank You to DyDr For This Useful Post:

    student101 (06-16-2018)

  8. #6
    Join Date
    Feb 2008
    Posts
    137
    Thanks
    18
    Thanked 2 Times in 2 Posts

    Default

    WORKING!!

    Thanks ALL for your help here!!

    Commented out the orange all working

    Code:
    $rssid=$_GET['id'];
    //$rssurl=isset($rsslist->$rssid)? $rsslist->$rssid : die("<b>Error:</b> Can't find requested RSS in list.");
    $cachetime=isset($_GET["cachetime"])? (int)$_GET["cachetime"] : 30; //Get cachetime. Default to 30 if not specified
    $feednumber=isset($_GET["limit"])? (int)$_GET["limit"] : ""; //Get number of items to fetch. If not specified (""), all is fetched.
    
    $templatename=isset($_GET["template"])? $_GET["template"] : ""; //get name of template, which is used by if/else logic within function outputbody()
    if ($templatename!="" && !preg_match("/^(\w|-)+$/i", $templatename)) //Template name can only contain alphanumeric characters, underscore or dash (-)
    die ("<b>Error:</b> Template name can only consist of alphanumeric characters, underscore or dash");
    
    //$rsslist->cache_max_minutes($cachetime);
    //$rsslist->feed_url($rssurl);
    $rsslist->init();
    $max = $rsslist->get_item_quantity($feednumber);
    
    ?>

Similar Threads

  1. Replies: 1
    Last Post: 03-26-2016, 02:37 PM
  2. Replies: 15
    Last Post: 05-10-2011, 03:55 AM
  3. Replies: 2
    Last Post: 07-13-2009, 10:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •