O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Create a Photo Album

Problem

I need to create a photo album.

Solution

Use the Photos.createAlbum() method, which unfortunately isn’t supported in the PHP Client Library (see Adding Missing PHP Client Library Methods):

$album = $facebook->api_client->photos_createAlbum('Test Album',
'Testville','This is a test');

Discussion

This method will return an array containing the information about your newly created album:

Array
(
    [aid] => 12345679012345
    [cover_pid] => 0
    [owner] => 12345
    [name] => Test Album
    [created] => 1212878578
    [modified] => 1212878578
    [description] => This is a test
    [location] => Testville
    [link] => http://www.facebook.com/album.php?aid=12345679012345&id=12345
    [size] => 0
)

You’re allowed to store the aid (album ID) and the uid of the owner, but nothing else. The returned cover_pid value will always be 0 because this album was just created and doesn’t contain any photos yet.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required