Need Help on Recent Blog Feed Import

Discussion in 'PHP' started by sultanofseo, Aug 22, 2009.

  1. #1
    Lets start by saying that I don't know anything about PHP. I hired a designer to do a site for me where I added the recent blog feed import option (main site + blog and 5 recent blog feed shows on the main site sidebar as recent blog feed). I'm working on a new site where I'm trying to add the same feature on imporitng 10 recent blog feeds on the main site which is not working. I copied the code form the previous site and uploaded the needed files as well but only 2 feeds show on the main site instead of 5 or 10. Here's the code I used on the main site index file:

    
    <div class="wrap">
    	<div id="siderss"><div class="bottom">
        	<h3>Latest blog entries</h3>
            <ul>
                <?php include('./magpie/rss_fetch.inc');
    
    // Set error reporting for this 
    error_reporting(E_ERROR);
    
    // Fetch RSS feed 
    $rss = fetch_rss('http://myurl.com/blog/feed');
    if ($rss) {
     // Split the array to show first 5  
     $items = array_slice($rss->items, 0, 5);
     
     // Cycle through each item and echo  
    foreach ($items as $item )
     {   echo '<li><a href="'.$item['link'].'">'.$item['title'].'</a></li>';  }
    }
    else
    {
      echo '<h2>Error:</h2><p>'.magpie_error().'</p>';
    }
    // Restore original error reporting value
    @ini_restore('error_reporting');
    ?> 
            </ul>
        </div></div>
    
    Code (markup):
    I uploaded the entire magpie folder from my previous site on my server but didn't make any change on any of the files within that folder. Any help?
     
    Last edited: Aug 22, 2009
    sultanofseo, Aug 22, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Add some debugging (test this in an offline version or in a copy of the file that is not accessible by others)

    
    if ($rss) {
     $items = array_slice($rss->items, 0, 5);
    echo "RSS";
    echo "<pre>";
    print_r($rss);
    echo "</Pre>";
    echo "ITEMS";
    echo "<pre>";
    print_r($items);
    echo "</Pre>";
    
    PHP:
    And show the output here. Btw, by 2 feeds, do you mean 2 feed items?
     
    premiumscripts, Aug 22, 2009 IP
    sultanofseo likes this.
  3. sultanofseo

    sultanofseo Notable Member

    Messages:
    9,930
    Likes Received:
    405
    Best Answers:
    0
    Trophy Points:
    265
    #3
    sorry for being dumb but where do i add this? before or after the code i posted above?

    yes, only 2 blog entires are being fetched
     
    sultanofseo, Aug 22, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Where the first "if ($rss " is (you'll replace the first line as you see.
     
    premiumscripts, Aug 22, 2009 IP