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?
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! 🙂
you didnt have anything to do with the beebs comments earlier about flickr account users being miffed at the yahoo id thing ? 😉
Heh . No. Over 700 replies to the post from flickr did that! 🙂
http://flickr.com/forums/help/32687/page8/#reply164982
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
Oops, would you mind editing out my key? Sorry, new at this.
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…
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.”
Or I could do a version which uses ‘curl’, if you have that
ALSO – It looks like you dont have the ‘simplexml’ functions
NB: You MUST have PHP5 with simplexml and fopen wrappers activated
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. 🙂
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
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!
Does your host support ‘curl’ ?
Yep, it does support curl, in fact it recommends curl as an alternative to the unsupported php functions.
Pingback: Anonymous
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?
🙂
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?
He posts to WOrdpress the dear. Here’s the url, even though I suspect you’ve seen this:
http://dedricmauriac.wordpress.com/
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 😉 )
Eeek! WordPress it is, then.:-)
By the way, that’s a really long finger.
All the better for wagging and pointing at things.
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.