My Story With Flickr

Embed Size (px)

DESCRIPTION

Just a simple story-mode how to work with the flickr api using the phpflickr class

Citation preview

  • 1. Using the flick r API to please my wife Background images downloaded from:http://profesorul09.webs.com/apps/photos/ My wife loves to take pictures, she also loves photo albums. Long time ago I wrote a little script for her that adds the original date to a photo using ImageMagick / This is the story of how to do the same inflick r Note: flick r automatically presents this info at the right side of any image if it contains this EXIF info -, but I really want to try to do it by myself

2. Why Flickr? / Which language

  • Because its a very cool web application, supported for one of the most talented team into the Web Development scene. Also because it offers an open API that allows to do it.
  • JAVA for a desktop app sounds really sweet

3. PHP for a web app sounds good too 4. What does this app going to do?

  • Using a previously uploaded image get its original date (the date it was taken) and add it as a Tag / comment

5. How does it will look like? 6. This time I chose PHP

  • I want to put this as a simple on-line application, so I chose PHP as my language and start looking for a class that actually implements the flickr API ( http://www.flickr.com/services/api/ ). On the flickr page I found phpflickr ( http://www.phpflickr.com/ ) a very complete class, without special requirements (ie: you don't need to have PHP compiled with or without specific extensions), so you just need to download it to start using it

7. Flowchart kind of

  • When the user loads the web application (from now on referred as just4fun) he/she will be required to start his/her flickr session. The reason for this is we want to gain access to all their images, and also, we want to write some info on them.

8. Once the user has logged into flickr is redirected to just4fun, when he/she can see a list of their albums. 9. The user click on any of their albums and gain access to the images inside of its selection. 10. The user click on any of the photos presented and just4fun add the date when the picture was taken as a comment and a tag inside flickr. 11. First Step: HTML Interface

  • Nothing special here, just one (kind of) cool trick, for my logo I used this:http://flickr.nosv.org/an on-line application that creates logos with your text that looks like the flickr one. In my code I call the result as the source for my image:
  • The rest of the code is just a couple of divs floating side by side

12. phpflickr lets begin the magic!

  • The first great thing with this class is you don't really need to take care about the authentication process in flickr and how your user would be redirected. Phpflickr includes a callback script called auth.php that could serve you as the backbone for this process. You only need to configure it using your api key and your secret

13. auth.php $api_key= " copy and paste your api key here "; $api_secret= " copy and paste your api secret here "; $default_redirect= "/"; $permissions= "read"; $path_to_phpFlickr_class = "./";

  • You don't need to change anything else in this file

14. In flickr ...

  • Now, assuming your application will be located onhttp://yourserver.comand you'll be using a lib subdirectory to store all the phpflickr files, you must define your callback url as:http://yourserver.com/lib/auth.php

15. And the index.php

  • Now let's take care of the index.php file, basically the only one the final user would see. First we need to call the class and use the auth.php script: