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

Get a User’s Info

Problem

I need to retrieve info about a specific user.

Solution

Use the Users.getInfo() method:

$uids = array('12345');
$fields = array('first_name','last_name');
$users = $facebook->api_client->users_getInfo($uids, $fields);

Discussion

You can query on any of the fields that make up the user table, which are documented in Figure 9-1. You might run into some of the privacy restrictions built-in to Platform, which limit the meeting_for, meeting_sex, religion, and significant_other_id fields to being visible to an app only when it has been added by a user. Users also have the option to limit the visibility of all fields except affiliations, first_name, last_name, name, and uid.

FQL equivalent

If you’d prefer to use FQL to access users, the equivalent query is:

SELECT uid, name, birthday FROM user WHERE uid IN ($uids)

See User Table for more information.

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