">mixi Developer Center (mDC)

mixi Apps

mixi Apps (English) » Technical Specification » PC » Use Photo Album

Use Photo Album

mixi has been providing a photo album service that enables users to upload photos to be shared with Friends or other users. These photos can be stored and organized by each album in the service.


In the mixi App specification, APIs are available for retrieving information of a created album and photos stored in each album and for mash up with other content. These APIs are compliant with the Albums API prescribed in OpenSocial 0.9.

Album Information

First of all, the opensocial.DataRequest.newFetchAlbumsRequest() is available for obtaining the information of any created album.

var req = opensocial.newDataRequest();
req.add(req.newFetchAlbumsRequest(opensocial.IdSpec.PersonId.OWNER), "albums");

The argument of the newFetchAlbumsRequest() indicates the user, which should be either of the following:

  • opensocial.IdSpec.PersonId.OWNER
  • opensocial.IdSpec.PersonId.VIEWER

Then, another request object can be added to the DataRequest object by using the add(). A request to a mixi server is made from the send() and the callback function receives a result from the server.

req.send(function(data) {
  var albums = data.get("albums").getData();
  albums.each(function(album) {
    var id = album.getField(opensocial.Album.Field.ID);
    var title = album.getField(opensocial.Album.Field.TITLE);
    // do something...

The each() enables the developer to retrieve the information of each album out of obtaining information of multiple albums stored in an opensocial.Collection object. The following information can be retrieved from the information:

  • Photo Album ID – album.getField(opensocial.Album.Field.ID)
  • Photo Album Title – album.getField(opensocial.Album.Field.TITLE)

Photo Information

By browsing URL of each photo retrieved out of information of the photo in a certain album, the photo can be displayed on a mixi App. In order to obtain information of the photo, the opensocial.Album.newFetchMediaItemsRequest() is available.

var albumId = ...;
var req = opensocial.newDataRequest();
        opensocial.IdSpec.PersonId.OWNER, albumId), "mediaItems");

The following argument can be specified for the newFetchMediaItemsRequest().

  • opensocial.IdSpec.PersonId.OWNER or opensocial.IdSpec.PersonId.VIEWER
  • Photo Album ID

By using the add(), a request object generated by the newFetchMediaItemsRequest() can be added to the DataRequest object . A request to a mixi server is sent by the send(), and the result is returned to the callback function from the server.

req.send(function(data) {
  var mediaItems = data.get("mediaItems").getData();
  mediaItems.each(function(mediaItem) {
    var thumbnailUrl = mediaItem.getField(opensocial.MediaItem.Field.THUMBNAIL_URL);
    var url = mediaItem.getField(opensocial.MediaItem.Field.URL);
    // do something...

By using the each(), information of each photo can be retrieved out of the information of multiple photos stored in an opensocial.Collection object. The following information can be retrieved from the information of the photo.

  • Original Photo URL – mediaItem.getField(opensocial.MediaItem.Field.URL)
  • Thumbnail URL – mediaItem.getField(opensocial.MediaItem.Field.THUMBNAIL_URL)
  • Description – mediaItem.getField(opensocial.MediaItem.Field.DESCRIPTION)

Current Restrictions

The following restrictions apply for the Albums API.

  • The available photo album/photo has to belong to either owner or viewer.
  • Only photo album or photo which set up as "open to the public" is available.