Submitted by mikesven on Sat, 05/09/2009 - 10:09
There have been a few projects in the past year or so that I have worked on where there has been the need to pull in a feed of information from Flickr to be used. Each time I would begin the process by looking back at a previous project and copying over a bunch of code into the document class of what I was working on. Well needless to say that got a little tiresome so I have decide to package up all of that code into a nice little class which returns an array of information based on your query. With this class you can go through a given users filckr library and return all images or any images with a given tag. For each image the 5 image size URLs along with the title and owner name will be returned. In order to use this class you will need two things. A valid Flickr API key, and you will also need to know the 11 character alphanumeric user id of the person who’s images you would like to pull. You can get a flickr API key by going here and clicking on the “Apply for a New API Key” link. To get the users alphanumeric ID, I used this website, which allows you to put in the users flickr url, and it will return their id. Once you have those two things you are ready to go. You can use the FilckrSinleUseresImagesByTags class by using the following code:
var flickrDataGatherer:FlickrSingleUsersImagesByTags( *user id of person to get images from, *your api key, *image tag that you would like to use, *number of images to get );
flickrDataGatherer.addEventListener(FlickrSingleUsersImagesByTags.FLICKR_DATA_READY, dataReady, false, 0, true);
flickrDataGatherer.loadImageInfo();
private function dataReady(e:Event):void{
var someArray:Array = flickrDataGatherer.information;
}
If you would like to download and use my flickr class I will make it available here. Feel free to use it in any of your projects, if it is going to save you some time. I’m hoping it will save me quite a bit in the future. If you have any comments or ideas for improvement please leave a message in the comments, I would love to hear what you have to say.
- mikesven's blog
- Log in to post comments