You are here: Facebook application developers forumFacebook development boardsApplication developmentUsing the FacebookRestClient Class’ “Photo” Methods, Part 1: photos_getAlbums
Pages: [1]
Using the FacebookRestClient Class’ “Photo” Methods, Part 1: photos_getAlbums

Starting with this article, I’m going to look at the methods concerned with photos, namely:

    * photos_get
    * photos_getAlbums
    * photos_getTags

In this article, I’ll look at the photos_getAlbums method.


photos_getAlbums

The photos_getAlbums method retrieves information about photo albums. It can:

    * Retrieve information about a given user’s photo albums
    * Retrieve information about any number of photo albums, given the photo albums’ IDs

In Facebook, photos don’t just exist on their own — every photo has to belong to an album. That’s why I’m covering this method first.

Input

photos_getAlbums takes two arguments — here’s its signature:

Quote
photos_getAlbums($uid, $aids)

The parameters it expects are explained below:

Parameter                   What It Is
$uid[optional][integer] The ID of the user whose photo albums are to be retrieved. If no value is provided, the current user's photo albums will be retrieved.
$aids[optional][array of integers] An array containing the IDs of phpto albums to retrieve. If no photo album IDs are given, the method will fetch all the albusm for the user specified in $uid.

Output

photos_getAlbums returns an array of associative arrays, with one element for each photo album. The associative array in each element is explained in the table below:

Array Element                   What It Is
aidAlbum ID - the unique identifier for the photo album.
cover_pidCover photo ID - the unique identifier for the album photo that will be used as the "cover" for the album.
ownerOwner ID - the ID of the user who owns the photo album.
nameThe name of the photo album.
createdThe date and time the photo album was created, expressed as a Unix timestamp in UTC time.
modifiedThe date and time the photo album was last modified, expressed as a Unix timestamp in UTC time.
descriptionA brief description of the photo album.
locationText that explains where the photos in the album were taken.
linkThe URL for the photo album's main page.
Note: Unlike users and groups, you can't deduce a photo album's URL from its album ID. This is because the album ID isn't used as a parameter for an album's URL.
sizeThe number of photos in the album.

Getting the Current User’s Photo Albums

Let’s start with the simplest case, in which we want to retrieve information about the current user’s photo albums. Calling photos_getAlbums without any arguments does the job:

Quote from: index.php: Get the photo albums of the current user
<?php

require_once 'appinclude.php';

echo("<pre>");
print_r($facebook->api_client->photos_getAlbums());
echo("</pre>");

?>

Here’s the output of that code, with me as the logged-in user. Naturally, your results will look different:

Quote from: Output of index.php
Array
(
   
  • => Array
        (
            [aid] => 2421870240750155075
            [cover_pid] => 2421870240751164382
            [owner] => 563885607
            [name] => Toronto, a.k.a. Accordion City
            [created] => 1187711532
            [modified] => 1187711589
            [description] => Random shots of mine from in and around Toronto.
            [location] => Toronto
            [link] => http://www.facebook.com/album.php?aid=46403&id=563885607
            [size] => 1
        )

    [1] => Array
        (
            [aid] => 2421870240750135353
            [cover_pid] => 2421870240750672685
            [owner] => 563885607
            [name] => Graphic Design Noodling
            [created] => 1181323540
            [modified] => 1181323664
            [description] =>
            [location] =>
            [link] => http://www.facebook.com/album.php?aid=26681&id=563885607
            [size] => 1
        )

    [2] => Array
        (
            [aid] => 2421870240750127055
            [cover_pid] => 2421870240750480103
            [owner] => 563885607
            [name] => Accordion Hijinx
            [created] => 1178156059
            [modified] => 1181312653
            [description] =>
            [location] =>
            [link] => http://www.facebook.com/album.php?aid=18383&id=563885607
            [size] => 41
        )

    [3] => Array
        (
            [aid] => 2421870240750118761
            [cover_pid] => 2421870240750303070
            [owner] => 563885607
            [name] => Pics of My Friends
            [created] => 1174674516
            [modified] => 1178594382
            [description] => Interesting or funny photos featuring my friends. Maybe you're in here!
            [location] =>
            [link] => http://www.facebook.com/album.php?aid=10089&id=563885607
            [size] => 30
        )

    [4] => Array
        (
            [aid] => 2421870240750127403
            [cover_pid] => 2421870240750487641
            [owner] => 563885607
            [name] => Geekin' Out
            [created] => 1178317424
            [modified] => 1178317504
            [description] => Random photos from geeky events, conferences and so on.
            [location] =>
            [link] => http://www.facebook.com/album.php?aid=18731&id=563885607
            [size] => 1
        )

)

Getting the Photo Albums of a Specified User

In order to retrieve information about all the photo albums belonging to a user who isn’t the current user, you need to specify that user’s ID in the $uid parameter and set the $aids parameter to NULL (or simply don’t provide any value for it).

Let’s get a look at Robert Scoble’s photo albums. His user ID is 501319654, so the code to retrieve his photo albums looks like this:

Quote from: index.php — Code to retrieve Scoble’s photo albums
<?php

require_once 'appinclude.php';

echo("<pre>");
print_r($facebook->api_client->photos_getAlbums(501319654));
echo("</pre>");

?>

Here are the results — it looks as though he’s got only one publicly viewable album:

Quote from: Output of index.php
Array
(
   
  • => Array
        (
            [aid] => 2153151518772038259
            [cover_pid] => 2153151518772126717
            [owner] => 501319654
            [name] => Robert Scoble's photos
            [created] => 1180999046
            [modified] => 1184371254
            [description] => My photos
            [location] => Half Moon Bay, CA
            [link] => http://www.facebook.com/album.php?aid=2675&id=501319654
            [size] => 49
        )

)

Getting Information About One or More Arbitrary Photo Albums

Finally, let’s retrieve information about a couple of photo albums whose IDs are known. In this case, we specify the albums’ IDs in the $aids parameter and set the $uid parameter to NULL.

Suppose we want to fetch information about these two photo albums:

    * My “Accordion Hijinks” photo album, whose ID is 2421870240750127055
    * Robert Scoble’s photo album, whose ID is 2153151518772038259

Quote from: index.php — Get info about a number of photo albums
<?php

require_once 'appinclude.php';

echo("<pre>");
print_r($facebook->api_client->photos_getAlbums(NULL, array('2421870240750127055', '2153151518772038259')));
echo("</pre>");

?>

Note that in the code, I put the photo album IDs in quotes. That’s because although the IDs are numeric, they’re too large to be represented as integers.

Here’s the output of the code:

Quote from: Output of index.php
Array
(
   
  • => Array
        (
            [aid] => 2421870240750127055
            [cover_pid] => 2421870240750480103
            [owner] => 563885607
            [name] => Accordion Hijinx
            [created] => 1178156059
            [modified] => 1181312653
            [description] =>
            [location] =>
            [link] => http://www.facebook.com/album.php?aid=18383&id=563885607
            [size] => 41
        )

    [1] => Array
        (
            [aid] => 2153151518772038259
            [cover_pid] => 2153151518772126717
            [owner] => 501319654
            [name] => Robert Scoble's photos
            [created] => 1180999046
            [modified] => 1184371254
            [description] => My photos
            [location] => Half Moon Bay, CA
            [link] => http://www.facebook.com/album.php?aid=2675&id=501319654
            [size] => 49
        )

)


Next Time…

In the next article, I’ll cover the photos_get method.





This material is a property of Joey deVilla. Please, visit his great blog for more Facebook stuff.
Logged
  • !!itellakerma
  • Newbie
  • *
  • Posts: 1
  • [url=http://www.buyaciphex.com/purchase-prilosec.html][b]purchase omeprazole[/b][/url]
  •  
  • View Profile WWW
purchase omeprazole
« Reply #1 on: September 19, 2009, 10:30:06 AM »

purchase ondansetron - Preventing nausea and vomiting due to cancer chemotherapy or surgery. hhc dsbeav
purchase esomeprazole - Treating heartburn or esophagitis (inflammation of the food pipe) due to acid reflux disease (GERD). rdnt hczmv
purchase misoprostol - Cytotec (Misoprostol) is used to prevent stomach ulcers while you take NSAIDs (e.g., aspirin, ibuprofen, naproxen). tqgc jabuv
purchase mebeverine - This medicine acts directly on the smooth muscle in the gut causing it to relax. rtbkex qen
purchase pantoprazole - The short-term treatment (7 to 10 days) of severe inflammation and erosion of the esophagus due to gastroesophageal... fejoqd fyq
purchase omeprazole - It is used to treat ulcers, gastroesophageal reflux disease, and other conditions gmc impikj
purchase propantheline -  sru dhyup
Pages: [1]
You are here: Facebook application developers forumFacebook development boardsApplication developmentUsing the FacebookRestClient Class’ “Photo” Methods, Part 1: photos_getAlbums
Jump to: