«

»

Sep 28

Flex and Flickr

So I sat down last night, and tried to learn the Flex library for building Flickr apps. (You can find the libraries at labs.adobe.com)

Good News

I was eventually able to get it to work.

Bad News

It took a long time to debug the library enough to make it work. I don’t think it’s been updated recently. I thought I would post this, in a hope that someone somewhere will find it, and it will help them avoid some of the problems that I had.

The Adventure

The Flickr library is dependent on the corelib, and you need to download both. Make sure you download the source – you’re going to need it!

You will also need a Flickr API key, which you can get from Flickr by logging in (create an account if you need to) and going here: http://www.flickr.com/services/ – to apply for a key.
Here’s what I discovered:

  • You can’t use the flickr.swc – you must either include the flickr api source code in your app, or recompile the flickr.swc file for yourself. I did the former.
  • You have to include the flickr api source code at the right directory – src/trunk/src/actionscript3
  • As a starting point for understanding how the Flickr api works, there are no tutorials. However, there is a manual test – src/trunk/tests/ManualFlickrTest/ManualFlickrTest.mxml
    • Note that it doesn’t work as is – you have to edit the code in a couple of places (see below)
  • You need to make several changes to the existing Flickr code:
    • src\trunk\src\actionscript3\com\adobe\webapis\flickr\FlickrService.as – you must change the two END_POINT urls – they need to be api.flickr.com, not just ‘flickr.com’ (I’ll explain why at the end)
    • src\trunk\src\actionscript3\com\adobe\webapis\flickr\methodgroups\Auth.as – you must change the checkToken function – where it says ‘false’ on line three of the MethodGroupHelper call, it needs to be ‘true’.
    • src\trunk\tests\ManualFlickrTest\ManualFlickrTest.mxml – In a couple of places (getFrobResponse & getTokenResponse), listeners attempts to get data directly from event.data. But you can’t. You have to get data from event.data.frob and event.data.auth, respectively.
  • If you try to test out ManualFlickrTest, be aware that it has hardcoded values for all of the parameters – so if you’re trying to use the API, it will probably return the wrong results until you go into the code and fix it.
  • And, here’s the punchline – this whole app is a big security hole, because you have to include your secret Flickr API key. That key lets a clever hacker pretty much do anything to your flickr account except change your password. So you can’t really put apps out there for public consumption.
    • I have a theoretical fix in mind for this problem, but it will take some time to write it. In the meantime, just beware!

Here’s the updated source code for the Flickr API for Flex

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>