4. Albums API
• Standardized in OpenSocial 0.9 spec
• Allows an app to create, delete, get and update albums and photos
• APIs for access using REST, RPC and JS
Google Confidential and Proprietary
5. Albums API
opensocial.MediaItem extended
represents a photo (or video) on orkut
Title, description, thumbnailUrl, albumId.. added
opensocial.Album introduced
represents a collection of MediaItems
has title, description, thumbnailUrl, ownerId, etc.
Google Confidential and Proprietary
6. Albums API: JS
opensocial.newFetchAlbumsRequest(idSpec, opt_params)
fetches albums for a user
opt_params to specify a particular album or for paging
opensocial.newFetchMediaItemsRequest(idSpec, albumId, opt_params)
fetches mediaitems in an album for a user
opt_params to specify particular mediaitems or for paging
opensocial.newCreateAlbumRequest() - create an album
opensocial.newUpdateAlbumRequest() - update an album
opensocial.newDeleteAlbumRequest() - delete an album
similarly for MediaItems
Google Confidential and Proprietary
7. Albums API: JS
req = opensocial.newDataRequest();
req.add(req.newFetchAlbumsRequest(idspec, params), 'albums');
req.send(processAlbums);
function processAlbums(data) {
var albums = data.get('albums').getData();
albums.each(function(album) {
output(album.getField(opensocial.Album.Field.ID));
output(album.getField(opensocial.Album.Field.CAPTION));
output(album.getField(opensocial.Album.Field.THUMBNAIL_URL));
});
}
Google Confidential and Proprietary
8. Albums API: REST and RPC
REST base: /social/rest/
• /albums/{userId}/{groupId}/{albumId}
• /mediaitems/{userId}/{groupId}/{albumId}/{mediaItemId}
RPC endpoint: /social/rpc
• methods: albums.create, albums.delete, albums.get and albums.update;
similarly for media items: mediaitems.create, mediaitems.delete,
mediaitems.get and mediaitems.update
Google Confidential and Proprietary
10. REST and RPC
REST and RPC services now available on orkut
• backend servers can initiate actions on orkut
• backend servers authenticate using OAuth
• visit http://google.com/directory/gadgets/verify to get consumer key and secret
for OAuth parameter signing
• open-source client libraries available on Google code
php, python, java and ruby clients
Google Confidential and Proprietary