Buying Need to Paginate RSS feed script

Discussion in 'Programming' started by IamNed, Dec 7, 2009.

  1. #1
    I have a script below that generates a multifeed from multiple RSS feeds. What I want is to paginate the results so instead of having 60 or more results on a single page I only have 10 or so.

    please PM price

    <?php
    // Include the SimplePie library
    require_once('../simplepie.inc');
     
    // Because we're using multiple feeds, let's just set the headers here.
    header('Content-type:text/html; charset=utf-8');
     
    // These are the feeds we want to use
    $feeds = array(
        'http://rss.news.yahoo.com/rss/topstories',
        'http://news.google.com/?output=atom',
        'http://rss.cnn.com/rss/cnn_topstories.rss'
    );
     
    // This array will hold the items we'll be grabbing.
    $first_items = array();
     
    // Let's go through the array, feed by feed, and store the items we want.
    foreach ($feeds as $url)
    {
        // Use the long syntax
        $feed = new SimplePie();
        $feed->set_feed_url($url);
        $feed->init();
     
        // How many items per feed should we try to grab?
        $items_per_feed = 5;
     
        // As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array.
        for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++)
        {
            $first_items[] = $feed->get_item($x);
        }
     
        // We're done with this feed, so let's release some memory.
        unset($feed);
    }
     
    // We need to sort the items by date with a user-defined sorting function.  Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function.
    function sort_items($a, $b)
    {
        return SimplePie::sort_items($a, $b);
    }
     
    // Now we can sort $first_items with our custom sorting function.
    usort($first_items, "sort_items");
     
     
    // Begin the (X)HTML page.
    ?><!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>Multifeeds Test page</title>
        <link rel="stylesheet" href="../demo/for_the_demo/simplepie.css" type="text/css" media="screen" title="SimplePie Styles" charset="utf-8" />
        <style type="text/css">
        div#site {
            width:600px;
        }
        span.footnote {
            white-space:nowrap;
        }
        h1 {
            line-height:1.4em;
        }
        .clearBoth {
            clear:both;
        }
        </style>
    </head>
    <body>
    <div id="site">
     
        <div class="chunk">
            <h1>Quick-n-Dirty Multifeeds Demo</a></h1>
        </div>
     
        <?php
        foreach($first_items as $item):
            $feed = $item->get_feed();
            ?>
     
            <div class="chunk">
                <h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></h4>
     
                <?php echo $item->get_content(); ?>
     
                <?php if ($enclosure = $item->get_enclosure()): ?>
                    <div>
                    <?php echo $enclosure->native_embed(array(
                        // New 'mediaplayer' attribute shows off Flash-based MP3 and FLV playback.
                        'mediaplayer' => '../demo/for_the_demo/mediaplayer.swf'
                    )); ?>
                    </div>
                <?php endif; ?>
     
                <p class="footnote">Source: <a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a'); ?></p>
            </div>
     
        <?php endforeach; ?>
     
     
    </div>
    </body>
    </html>
    PHP:

     
    IamNed, Dec 7, 2009 IP
  2. meganet

    meganet Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    i can do this for u immediately

    PM me for with more details
     
    meganet, Dec 7, 2009 IP
  3. webcoder

    webcoder Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    WE can do immediate
     
    webcoder, Dec 7, 2009 IP
  4. sastro

    sastro Well-Known Member

    Messages:
    214
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    sastro, Dec 7, 2009 IP
  5. frank007

    frank007 Well-Known Member

    Messages:
    160
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Check PM...
     
    frank007, Dec 8, 2009 IP
  6. deang

    deang Guest

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Hi Ned, please check your PM's, message sent.

    Regards
    Deano
     
    deang, Dec 8, 2009 IP
  7. mdsraj

    mdsraj Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    hi,

    I'm interested to do your work, PM sent
     
    mdsraj, Dec 8, 2009 IP