Facebook Getting information about an album

Getting information about an album

To get information about a single album, your code could look something like:

// Make a request to the Graph API
FacebookAlbumResponse response = service.Albums.GetAlbum("847998698580153");

// Get information about the album from the response
FacebookAlbum album = response.Body;

// Write some of the album information to the console
Console.WriteLine("ID: " + album.Id);
Console.WriteLine("Name: " + album.Name);

Fields

The Facebook Graph API exposes a number of fields/properties that are not returned by default. For these to be returned, you need to specify these fields explicitly:

// Initialize a collection of the fields we wish to be returned by the Graph API
FacebookFieldsCollection fields = (
    FacebookAlbumFields.Id +
    FacebookAlbumFields.Name +
    FacebookAlbumFields.Description +
    FacebookAlbumFields.Place
);

// Make a request to the Graph API
FacebookGetAlbumResponse response = Model.Albums.GetAlbum("215917305407", fields);

// Get information about the album from the response
FacebookAlbum album = response.Body;
    
// Write some of the album information to the console
Console.WriteLine("ID: " + album.Id);
Console.WriteLine("Name: " + album.Name);
Console.WriteLine("Description: " + album.HasDescription ? album.Description : "No description");
Console.WriteLine("Place: " + album.HasPlace ? album.Place.Name : "No place");

You can find constants for most of the supported fields in the FacebookAlbumFields class or consult the Graph API documentation for further information.