CFlickr - Coldfusion Flickr API Kit
This is the beta release of CFlickr, it has been tested quite abit, but you're likely to find the odd bug or two. If you do please let me know by emailing me at chris@m0nk3y.net
Introduction
CFlickr is an API Kit for Coldfusion, it wraps the Flickr's REST API making it even easier to use within your CFML code.
I was inspired to write CFlickr after using the Java Flickr library FlickrJ from within Coldfusion. Whilst this worked well under most circumstances it was not convenient to use in a shared hosting environment due to the installation of the class files in the servers classpath. So i decided to write CFlickr in 100% native CFML, which can be used without any dependencies. It should work with versions CFMX6.1 and later.
Download
You can download the latest version here
Installation
Copy the CFlickr folder to your webroot, or create a mapping in the Coldfusion Administrator that points to this directory (it must be called CFlickr)
Documentation
CFC Documentation available here
Example Usage
<!--- Create an instance of the Flickr class--->
<cfset flickr = createobject("component", "CFlickr.Flickr")>
<cfset flickr.init(apikey [,secret] [,token])>
<!--- Get the interface we want to work with --->
<cfset interestingInterface = flickr.getInterestingnessInterface()>
<!--- Get the 10 most interesting photos for today --->
<cfset photoList = interestingInterface.getList(per_page=10,page=1)>
<cfset arrayPhotos = photoList.getPhotos()>
<!--- Loop over the photos and output a thumbnail of each --->
<cfloop from="1" to="#arraylen(arrayPhotos)#" index="i">
<cfset photo = arrayPhotos[i]>
<cfoutput>
<img src="#photo.getPhotoUrl(photo.SIZE_SMALL_SQUARE)#" />
</cfoutput>
</cfloop>
NOTE: CFlickr should not be placed in the application scope as it stores the users token, it is safe to place it within the session scope. I will try to address this in a future version, so that an application can use a single instance of CFlickr for all users.
Examples
You will need an API Key to use the examples, you can apply for one here
| |
Description |
Required |
Permissions |
| Example 1 |
Requesting authentication from Flickr, and getting a user id and token back |
API Key, Secret |
None |
| Example 2 |
Publishing a photo to a blog using the API |
API Key, UserID, Token |
Read |
| Example 3 |
Using the comments and interestingness interfaces |
API Key |
None |
| Example 4 |
Retrieving a list of contacts |
API Key, UserID, Token |
Read |
| Example 5 |
Retrieving photosets and photos |
API Key |
None |
| Example 6 |
Creating simple tag cloud and searching for a users photos by tag |
API Key |
None |
| Example 7 |
Flickr API Explorer using reflection interface |
API Key |
None
|
| Example 8 |
Upload Example |
API Key, Token |
Write |
| Example 9 |
Compares Methods in CFlickr to equivalents in Flickr API |
API Key |
None |
History
| Date |
Version |
Comments |
| 13/08/2007 |
0.7 |
CFlickr.photos.geo.GeoInterface
- Argument accuracy for method setLocation() is now optional to match the API
CFlickr.urls.UrlsInterface
- Argument url for methods lookupGroup() and lookupUser() is now required to match the API
CFlickr.prefs.PrefsInterface
- New interface for prefs
- getContentType() Returns the default content type preference for the user
- getHidden() Returns the default hidden preference for the user
- getSafetyLevel() Returns the default safety level preference for the user
CFlickr.photos.PhotosInterface
- Added method setSafetyLevel()
CFlickr.Flickr
- Added method getVersion()
|
| 29/05/2007 |
0.61 |
CFlickr.photos.Photo
- Fixed bug in getPhotoUrl() which caused original image url's to be returned with the wrong secret
|
| 24/03/2007 |
0.6 |
Caching
- Added ability to cache responses from the Flickr API.
- Includes classes for caching to memory, file or a MySQL database.
- Alternative caching mechanisms can be created my extending the AbstractCache class and implementing its public methods.
Examples
Documentation
- Thanks to some apache mod_rewrite magic i've reformatted the docs so that they reflect the package tree instead of one big flat list of files.
|
| 25/2/2007 |
0.5 |
CFlickr.AbstractObject
Most objects now extend this class
- _dump() returns a struct containing the value of all get() methods, useful for debugging
- _iso_dateformat() private method for date formatting
- _unix_dateformat() private method for date formatting
CFlickr.Flickr
- getTransformInterface() added, the interface existed but there was no method to get it
CFlickr.photos.Photo
- get/setOriginalFormat() added
- get/setOriginalSecret() added
- get/setFarm() added
- getPhotoUrl() now returns correct original format (png,gif,jpg) and uses originalsecret when original size is requested
CFlickr.photosets.Photoset
- Now extends CFlickr.photos.PhotoList, parsing of child photo elements is now handled by the Photolist class
General
- All Objects that extend CFlickr.AbstractList now override the add/remove/set/getItems() methods with their own
CFlickr.activity.ActivityInterface
- New interface for activity
- See also CFlickr.activity.ActivityList
CFlickr.favorites.Favoriter
- A user who has a photo as a favorite
- See also CFlickr.favorites.FavoriterList
Examples
- Upload Example (requires authentication with "write" perms)
- New CFlickr Introspection / comparison with Flickr API example
|
| 16/10/2006 |
0.41 |
CFlickr.tags.Tag
- get/setScore() methods added.
- get/setRawList() methods added.
CFlickr.tags.TagsInterface
- getHotList() Method added
|
| 03/09/2006 |
0.4 |
CFlickr.Flickr
- getCommentsInterface() deprecated, see below
- getPhotoCommentsInterface() added
- getPhotosetsCommentsInterface() added
CFlickr.comments.CommentsInterface
- This interface is now deprecated in favour of the new CommentsInterfaces for photos and photosets
CFlickr.photos.Photo
- getCanAddMeta() now returns an integer
- setCanAddMeta() now accepts an integer
- getCanComment() now returns an integer
- setCanComment() now accepts an integer
See CFlickr or Flickr API documentation for values
CFlickr.photos.Permission
- New object to represent perissions for photos and geotagging.
CFlickr.photos.PhotosInterface
- getContactsPhotos(), changed arguments just_friends, single_photo and include_self to boolean.
- getContactsPublicPhotos() changed arguments just_friends, single_photo and include_self to boolean.
- getNotInSet() changed argument privacy_filter to integer. See documentation for values.
- getUntagged() changed argument privacy_filter to integer. See documentation for values.
- getPerms() now returns a CFlickr.photos.Permission object.
- recentlyUpdated() method added
- search() added bbox and accuracy arguments to enable searching for photos by location.
- setDates() all arguments apart from photo_id are now optional
CFlickr.photos.comments.CommentsInterface
- New interface for photo comments
CFlickr.photosets.comments.CommentsInterface
- New interface for photoset comments
CFlickr.photosets.PhotosetsInterface
- delete() now returns void
- editMeta() now returns void
- editPhotos() now returns void
CFlickr.photos.geo.GeoInterface
- New GeoInterface to add support for the new flickr.photos.geo methods
CFlickr.urls.UrlsInterface
- lookupGroup() now returns a Group object
- lookupUser() now returns a User bbject
Documentation
- All interface methods and arguments are now hinted, mostly using text from the Flickr API explorer
Examples
- Added Flickr API Explorer example, using ReflectionInterface
|
| 28/08/2006 |
0.3 |
Changed Flickr REST endpoints to http://api.flickr.com |
| 02/08/2006 |
0.2 |
Minor bug fixes, mainly for compatibility with CFMX 6.1 |
| 13/07/2006 |
0.1 |
Initial Release, please report any bugs/errors to chris@m0nk3y.net |
Acknowledgements
CFC Documentation generated using CFCDoc package by Stephen Milligan, static version created using HTTrack
License
This software is licenced under the CC-GNU GPL.
You are free to use, distribute or modify it as long as any derivitaive works are in turn released under the GNU GPL licence.