Results 1 to 7 of 7

Thread: RSS Feed Help

  1. #1
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question RSS Feed Help

    Hi All,

    I have a simple RSS feed displayer for my website, but it is not working, I have tried to go through the code ans see what's wrong but I can't seem to find anything, if you could help that would be great

    PHP Code:
    <?php
    if ($rss DOMDocument::load('http://companynewssepro.blogspot.com/feeds/posts/default?alt=rss')) {
    $feed = array();
    foreach (
    $rss->getElementsByTagName('item') as $node) {
    $feed[] = array(
    'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
    'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
    'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
    );
    }
    $limit 10;
    foreach(
    $feed as $index => $feed_item) {
    //If the index (current number in array) is greater or equal to your limit stop processing.
    if ($index >= $limit)
    break;
    $feed_item = (object)$feed_item;
    $title htmlentities(strip_tags($feed_item->title));
    $link $feed_item->link;
    $description htmlentities(strip_tags($feed_item->desc));
    $date date('l F d, Y'strtotime($feed_item->date));
    echo 
    '<font class="rss-title">'.$title.'</font><br />'//
    echo '<font class="rss-disc">'.$description.'</font><br />'//
    echo '<font class="rss-date">Posted on '.$date.'</font><p>';
    }
    }
    ?>
    Thanks Guys
    Last edited by jscheuer1; 12-21-2013 at 02:12 AM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Seems to work OK to me. I get:

    MERRY CHRISTMAS
    Merry Christmas from all here at StormsEdge Productions and may 2014 be a wonderful year for everyone
    Posted on Tuesday December 17, 2013
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    BTW, the code requires PHP 5 or later.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Sorry John, i'm a bit of a PHP noob (i got this script of the internet somewhere) what do i need to do as u said it requires PHP 5 or later?

    Thanks

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    There could also be other requirements like permission to open and read files. Look at your phpinfo() to see what version you're running. If you don't already have phpinfo, just make up a file:

    PHP Code:
    <?php
    phpinfo
    ();
    ?>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    juliet1 (12-23-2013)

  7. #6
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi John, im runing 5.4.21 on my server

  8. #7
    Join Date
    Dec 2009
    Posts
    54
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Hi John, just thought illd let you know that I sorted it out, the error was a setting on my hosts cp

Similar Threads

  1. Replies: 3
    Last Post: 08-29-2012, 05:34 PM
  2. Replies: 0
    Last Post: 10-19-2011, 03:35 PM
  3. RSS Feed Reader (gfeedfetcher) isn't updating second feed
    By kellyrnh in forum Dynamic Drive scripts help
    Replies: 15
    Last Post: 08-13-2011, 06:16 AM
  4. Help with RSS Feed
    By fodo in forum PHP
    Replies: 0
    Last Post: 07-17-2009, 05:37 PM
  5. Replies: 0
    Last Post: 12-20-2008, 10:14 AM

Tags for this Thread

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
  •