Broadcast on Broadcast off
The Documentation for Project Zero has moved. Please update your bookmarks to: http://www.projectzero.org/documentation/
Table of
Contents...
Hide

Project Zero Developer’s Guide

Concepts and components
Basic concepts overview
Event processing
Writing Java handlers
Writing Groovy handlers
Firing events
Global Context
Global Context reference
Application directory layout
Virtualized directories
Assemble
PHP
Features and configuration
Configuration
Debugging
Dependencies
Packaging
Application classpath
Logging and tracing
RESTful resources
RESTful documentation
File serving
Response rendering
Validators and validation
HTTP error handling
Calling a remote resource
Using the Connection API
Sending an email using EmailConnection
Configuring destinations
Configuring protocols
Configuring connection handlers
Creating a connection handler
Creating a custom protocol transport
Simple logging connection handlers
Protocol reference
Client programming with Dojo
Runtime options
Deployment modifications
HTTP configuration
SSL configuration
Proxy configuration
Extending the CLI
Security considerations
Authentication
OpenID authentication
Extending security
Security tokens
CSRF prevention support
Extending token support
Leveraging TAI
User service
File based user service
LDAP user service
Extending user service
Security Utilities
Leveraging XOREncoder
Extensions
Atom support
RSS support
JSON support
XMLEncoder
REST to SOAP extension
URIUtils
Developer Web tools
Database setup tools
Configuring data access
Common query patterns
Advanced query patterns
Update patterns
Local database transactions
Extending data access
Configuration vendor differences
PHP data access
Resource model
Configuring ZRM
Resource model declaration
Programmatic model API
HTTP REST API
A ZRM mini tutorial
Active content filtering support
Default filters
Custom filters
Runtime management
Management commands
Zero socket opener
Other extension modules
Amazon E-commerce service
Flickr service
WeatherZero forecast service
Wikipedia service
Reference
Zero command line interface
JavaDoc - Public API
JavaDoc - Public SPI
JavaDoc - All Classes

 

Flickr services

This Project Zero extension provides an easy way to read and write Flickr's photo data from Java or Groovy without creating cumbersome request URLs. All requests made through this API are serviced by Flickr's REST API. You need a Flickr account and an API key to use the extension.

Adding Flickr to your project

You can access the Project Zero API for Flickr by adding the zero:zero.flickr module to your project. To do this, add the following line to your config/ivy.xml file:

<dependency org="zero" name="zero.flickr" rev="1.0+"/>

Add your Flickr API key to the zero.config file of your application, as shown in the following example:

/config/flickr/key = 1234567890

To access the Project Zero API for Flickr from your Java code, you can use the zero.flickr.FlickrClient class directly; from Groovy code, you can use the flickr variable, which is automatically added to the scope of your Groovy scripts.

Reading user and photo data

To query user and photo data using the extension, provide a method name and a set of parameters to the query() method, as shown in the following example:

def method = "flickr.photosets.getPhotos";
def params = [
    photoset_id: 1234567890, 
    page: 1, 
    per_page: 20
];
def response = flickr.query(method, params);  // response is a JSON object

If you query a method that returns one or more photo data structures, you can easily obtain the various URLs to the actual images:

for (i in 0 .. response.photoset.photo.length - 1)
{
    def thumbnailURL = thumbnail(response.photoset.photo[i]);
    def smallURL = small(response.photoset.photo[i]);
    def mediumURL = medium(response.photoset.photo[i]);
    def originalURL = original(response.photoset.photo[i]);

    // use URLs to set <img/> tags...
}

Modifying user and photo data

You can modify or delete Flickr data using the post() and delete() methods. These are very similar to the query() method call with the additional requirement that the user be authenticated. Flickr's documentation describes setting up authentication for applications that integrate with its service; the Zero API can help you implement this scheme with the createSignature() method.

You can use createSignature() to create the API call signature required of write-only methods. The parameters you use with this method are your Flickr API (that you got when you registered for your API key) and the parameters you intend to pass to the method. The implementation uses these values to generate a Flickr-approved signature value.

r3 - 07 Feb 2008 - 21:26:08 - paynel
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site