Random Rss feeds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • feelgoodmovies
    Registered User
    • Dec 2011
    • 33

    #1

    Random Rss feeds

    After scouring this forum, hot scripts and google with no luck- I have a question. Does anyone know a way to have rss feeds randomly display on your non-wordpress site. In other words I want to shuffle say ten different rss feeds and have one display content each time web page is loaded. I have the displaying part down(using rss2html and I also used an awesome script provided by this forum) but can't figure out the random(shuffling) part. Thanks.
  • rweb
    Registered User
    • Feb 2012
    • 24

    #2
    If you're using the rss2html php-script which can be downloaded from www[dot]feedforall[dot]com/more-php.htm then you can add something like that in this script:
    PHP Code:
    $myfeeds[]='url_of_the_feed_1';
    $myfeeds[]='url_of_the_feed_2';
    $myfeeds[]='url_of_the_feed_3';
    $myfeeds[]='url_of_the_feed_4';
    $myfeeds[]='url_of_the_feed_5';
    $myfeeds[]='url_of_the_feed_6';
    $myfeeds[]='url_of_the_feed_7';
    $myfeeds[]='url_of_the_feed_8';
    $myfeeds[]='url_of_the_feed_9';
    $myfeeds[]='url_of_the_feed_10';
    $XMLfilename = rand(0,sizeof($myfeeds)-1); 
    
    Add this in the script where there is the line "$XMLfilename = "sample.xml";" by default.
    Chaturbate plugin for WordPress | Simple tube plugin for WordPress

    Comment

    • feelgoodmovies
      Registered User
      • Dec 2011
      • 33

      #3
      How do I call that

      Thanks much for your help. So, I have replaced in the rss2html.php file like you mentioned. Now I am wondering how do I call this from my index.php page. Normally with rss2html you call with the following:


      <?php include'URL OF RSS2HTML FILE?XMLFILE=YOUR RSS FEED URL&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; ?>

      Comment

      • rweb
        Registered User
        • Feb 2012
        • 24

        #4
        Just remove the "XMLFILE=YOUR RSS FEED URL" part. Then it will use the random feed that you configured in the rss2html.php
        Like that:
        <?php include'URL OF RSS2HTML FILE?TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; ?>

        Or you can leave the rss2html.php as it is by default and do the randomization in your index.php file. In that case you should write in your index.php:
        PHP Code:
        <?php
        $myfeeds[]='url_of_the_feed_1';
        $myfeeds[]='url_of_the_feed_2';
        $myfeeds[]='url_of_the_feed_3';
        $myfeeds[]='url_of_the_feed_4';
        $myfeeds[]='url_of_the_feed_5';
        $myfeeds[]='url_of_the_feed_6';
        $myfeeds[]='url_of_the_feed_7';
        $myfeeds[]='url_of_the_feed_8';
        $myfeeds[]='url_of_the_feed_9';
        $myfeeds[]='url_of_the_feed_10';
        $XMLfilename = rand(0,sizeof($myfeeds)-1);
        include 'URL OF RSS2HTML FILE?XMLFILE='.$XMLfilename.'&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20';
        ?>
        Chaturbate plugin for WordPress | Simple tube plugin for WordPress

        Comment

        • feelgoodmovies
          Registered User
          • Dec 2011
          • 33

          #5
          Configuration error message.

          Thanks for your help. I tried both examples above and am getting the following error message: Unable to open RSS Feed 6, exiting Unable to open RSS Feed sample.xml, exiting .
          I made sure all files are chmod to 755 and changed this line in the rss2html.php script:

          $fileAccessLevel = 1;

          to this:

          $fileAccessLevel = 0;

          per their forum.

          Comment

          • rweb
            Registered User
            • Feb 2012
            • 24

            #6
            Sorry, I made a mistake.
            PHP Code:
            rand(0,sizeof($myfeeds)-1) 
            
            should be actually
            PHP Code:
            $myfeeds[rand(0,sizeof($myfeeds)-1)] 
            
            The include line like that
            PHP Code:
            include 'URL OF RSS2HTML FILE?XMLFILE='.$XMLfilename.'&TEMPLATE=URL OF TEMPLATE/sample-template.html&MAXITEMS=20'; 
            
            may not work on all servers.

            I tested on my server. I left the rss2html.php as it was. And in index.php I put:
            PHP Code:
            <?PHP
            $myfeeds[]='myfeedurl1';
            $myfeeds[]='myfeedurl2';
            $XMLFILE = $myfeeds[rand(0,sizeof($myfeeds)-1)];
            $TEMPLATE = "sample-template.html";
            $MAXITEMS = "20";
            include("rss2html.php");
            ?>
            And it worked. (My index.php is in the same directory as the rss2html.php.)
            Chaturbate plugin for WordPress | Simple tube plugin for WordPress

            Comment

            • feelgoodmovies
              Registered User
              • Dec 2011
              • 33

              #7
              Works like a charm.

              Thank you very much!!!!! You rock!!!!!!!!!!!!!!!

              Comment

              Working...