Putting RSS feed into site and having it archive itself

Discussion in 'Programming' started by tubeyak, Jul 29, 2007.

  1. #1
    I want to put an rss feed into a blog (or html site) and having it archive itself so that the next day when the feed is updated, it doesn't overwrite the old content but saved the old content.

    Thanks.
     
    tubeyak, Jul 29, 2007 IP
  2. Vangs

    Vangs Peon

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you just looking to backup the RSS feed before updating with the new content? If so you can do it in PHP with something a little like this:

    <?php
    
    $filecontent = ''; //make this your new RSS content
    
    $backupname = 'RSS Backup - '.date('d m Y', time()).'.xml';
    
    copy('/path/to/file.xml', '/path/to/'.$backupname);
    
    $handle = fopen('/path/to/file.xml', 'w');
    fwrite($handle, $filecontent);
    fclose($handle);
    
    ?>
    PHP:
     
    Vangs, Jul 29, 2007 IP
    tubeyak likes this.
  3. tubeyak

    tubeyak Active Member

    Messages:
    1,247
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I don't know programming so let me clarify what I want and you can tell me if the code you pasted would do it. I want to backup the feed as content on my site. I don't want to lose the content each day when the feed is updated. I'd want it to archive as a page within the site or blog.
     
    tubeyak, Jul 29, 2007 IP
  4. Vangs

    Vangs Peon

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The code I posted above takes your current RSS file, and makes a copy of it, renaming it in this format: 'RSS Backup - 29 07 2007.xml'. It then overwrites the normal RSS file the new content. This way you'll have a daily backup of the RSS file (assuming you run the script everyday).

    With regards to putting it into your site, I don't know if you want to just extract the data from the RSS feed and format it on the page, or if you want to actually store the backup as formatted HTML.
     
    Vangs, Jul 29, 2007 IP
  5. tubeyak

    tubeyak Active Member

    Messages:
    1,247
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Extract the content and format it on the page.

    For instance: http://www.rsstoblog.com/ I wanted to be able to do that on my site.
     
    tubeyak, Jul 29, 2007 IP
  6. tubeyak

    tubeyak Active Member

    Messages:
    1,247
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    80
    #6
    Thanks Vangs for all your help. Truly a great dper.
     
    tubeyak, Jul 29, 2007 IP