Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP code to edit RSS file

  • 04-06-2007 10:18am
    #1
    Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭


    Hi Lads,

    I'm slowly getting there with my flickr slideshow problem.

    I've discovered that google do a nice ajax feed api that takes in rss and creates a slideshow of it.

    My next problem is that flickr rss outputs the small version of the thumbnail

    EG
    <media:thumbnail url="http://farm1.static.flickr.com/214/499483509_84fdd2043b_s.jpg" height="75" width="75" />
    

    So what I want to do is to keep the rest of the rss and just edit the thumbnail section so it looks like this.
    <media:thumbnail url="http://farm1.static.flickr.com/214/499483509_84fdd2043b" />
    

    Is there a few simple commands that will do this for me?
    i.e.
    take in an html file
    replace - _s.jpg" height="75" width="75 with .jpg
    and just print the rest?

    Thanks for your help
    Gary

    P.S. Seems like a perl job but would like to do it in php


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    Here's a pretty basic example of str_replace() to get the ball rolling
    <?php
    $original_string = '<media:thumbnail url="http://farm1.static.flickr.com/214/499483509_84fdd2043b_s.jpg" height="75" width="75" />';
    $stuff_to_remove = '_s.jpg" height="75" width="75" />';
    $replace_with = '" />';
    $new_string = str_replace ($stuff_to_remove, $replace_with, $original_string);
    echo $new_string;
    ?>
    


  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


    Thanks for that, ya I kinda get the string replace.

    I guess my problem is taking the data from an rss file and assigning it to a variable within php.

    i.e. something like

    $original_string = http://api.flickr.com/services/feeds/photos_public.gne?id=8115115@N08&format=rss_200


  • Registered Users, Registered Users 2 Posts: 3,428 ✭✭✭randombar


    Apologies to all I'm a lazy idiot:
    <?php
    
    $myFile = 'http://api.flickr.com/services/feeds/photos_public.gne?id=8115115@N08&format=rss_200';
    $content = file_get_contents($myFile);
    if ($content !== false) {
       $remove = '_s.jpg" height="75" width="75" />';
       $replace = '.jpg" />';
       $new_content = str_replace ($remove, $replace, $content);
       echo $new_content;
    } else {
      echo "Error";
    }
    
    ?>
    


Advertisement