Free PHP5 Script to grab YOUR flickr Photos

UPDATED: To support Curl, if it is installed. It appears that some servers have the ‘fopen’ wrapper disabled, preferring Curl - which is faster too ! )

OK, so I have just knocked up a PHP5 script which, WITH SOME MORE WORK (on your part) will grab all your photos from flickr, should you want to move away from them.

This script takes your screen name and then lists all your photos, with the original photo file url, the title, description and any tags, comments and geocoding data too.

That’s as far as I go - the script is not doing any downloading at all - I leave the rest up to you :) You could add the details to a database, store images anywhere you like, ftp them somewhere - it’s up to you to get the PHP to do what you want.

If I get the time, I will create a desktop version which does the same thing. The tricky bit might be deciding on a static xml format for all the rest of the data - maybe a big RSS file would do. Or OPML. Or both?

Here is the PHP5 SOURCE.

NB: You MUST have PHP5 with simplexml and fopen wrappers or Curl activated (Some webhosts prefer you to use Curl, so they deactivate file_get_contents)

Enjoy! Feel free to use this code and hack and mash it up at will. Please add to the comments of this post, if you do extend it. Cheers! :)

21 Comments

  1. Comment by on January 31, 2007 6:17 pm

    you didnt have anything to do with the beebs comments earlier about flickr account users being miffed at the yahoo id thing ? ;)

  2. Comment by on January 31, 2007 6:19 pm

    Heh . No. Over 700 replies to the post from flickr did that! :) http://flickr.com/forums/help/32687/page8/#reply164982

  3. Comment by on January 31, 2007 6:51 pm

    Thanks for this! It’s exactly what I’m looking for. Sadly though, I’m getting the following errors. Think I did something wrong? This is a fresh api key, I entered it into the script as directed.

    Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in (my path to the script) on line 65

    Warning: file_get_contents(http://api.flickr.com/services/rest/?api_key=xxxxxxxxxxxxedit out ant the request of the commenter xxxxxxxxxxxxxxxxxx&method=flickr.people.findByUsername&username=myusername) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in (my path to the script) on line 65

    Fatal error: Call to undefined function: simplexml_load_string() in (my path to the script) on line 66

  4. Comment by on January 31, 2007 6:55 pm

    Oops, would you mind editing out my key? Sorry, new at this.

  5. Comment by on January 31, 2007 7:06 pm

    Hi,

    this looks like your server cont allow the file_get_contents

    There is another way I could do this, if you cant change your config.

    using fopen etc…

  6. Comment by on January 31, 2007 7:07 pm

    From the php page about this function

    “Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and Appendix M for a list of supported URL protocols.”

  7. Comment by on January 31, 2007 7:07 pm

    Or I could do a version which uses ‘curl’, if you have that

  8. Comment by on January 31, 2007 7:08 pm

    ALSO - It looks like you dont have the ’simplexml’ functions

    NB: You MUST have PHP5 with simplexml and fopen wrappers activated

  9. Comment by on January 31, 2007 7:41 pm

    Hey, nice hack.

    Personally, I think Flickr’s announcements today are no big deal.

    However, I’ve love to see another photo sharing site use something like this to give me the option of moving my photos over one day if I wanted to. Options are good. :)

  10. Comment by on January 31, 2007 7:52 pm

    Zooomr will have this option in version III ;)
    Very much like I was able to import all my old blogger.com posts here, when I moved to Wordpress

  11. Comment by on January 31, 2007 8:15 pm

    Ah, gotcha. I just checked and sure enough, my host has disabled file_get_contents and fopen. I’ll try to hack together a workaround. Thanks a bunch!

  12. Comment by on January 31, 2007 10:06 pm

    Does your host support ‘curl’ ?

  13. Comment by on January 31, 2007 10:39 pm

    Yep, it does support curl, in fact it recommends curl as an alternative to the unsupported php functions.

  14. Pingback by on February 1, 2007 9:16 am

    […] onovertroffen Kosso heeft al een PHP script klaar dat je helpt migreren; ik vermoed dat hij behoorlijk wat hits gaat […]

  15. Comment by on February 1, 2007 6:43 pm

    Er, now that you did this, could you work on a blogHUD to OPML blog thingie, so I can do posts like Dedrice Mauriac?
    Doesn’t hurt to ask now, does it? :-)

  16. Comment by on February 1, 2007 6:53 pm

    Post to OPML blog? I have been asking Dave about supporting that for a while. What do you mean about Dedric’s posts? eh? What’s he been up to?

  17. Comment by on February 1, 2007 6:58 pm

    He posts to WOrdpress the dear. Here’s the url, even though I suspect you’ve seen this:
    http://dedricmauriac.wordpress.com/

  18. Comment by on February 1, 2007 7:11 pm

    Ooooh. you just mean crosspost to a blog via bloghud? Unfortunately, the OPML blogs don’t support the MetaWeblog API - which I find odd in a way.

    If you want to do that, you’d have to switch to one of the supported blogging systems.

    (another reason why my OPML blog doesn’t have (as) much activity these days ;) )

  19. Comment by on February 1, 2007 7:45 pm

    Eeek! Wordpress it is, then.:-)
    By the way, that’s a really long finger.

  20. Comment by on February 1, 2007 11:00 pm

    All the better for wagging and pointing at things.

  21. Comment by on February 1, 2007 11:11 pm

    Also, there’s no reason why you cant get an rss widget and slap that on your OPML blog, so ppl and still see what’s going on.

Comments RSS TrackBack Identifier URI

Leave a comment

  • my playlist

      loading widget ...