tags:

views:

97

answers:

2

Hello All,

how can i get a facebook user's info like name, country, etc without making him login using fb connect, etc if i already know his facebook id?

I mean can i use the php facebook client to get those details without prompting for login if i already know the facebook id?

Thanks in advance :)

+3  A: 

You can't get that information with just a facebook id unless the person who the information belongs to made that information public (which almost noone has).

The only solution I see is to ask your users for the extended permission "offline_access". As far as I know you can only do this from within a facebook application or through the Facebook Connect javascript library (so not with the PHP library for instance).

This means that you will have to ask users to login at facebook through fb:connect atleast once, ask for offline access and store the facebook sessionKey in your local database. Because you have offline access now, the facebook sessionKey won't expire and you can login serverside without the user being present.

This is how I implemented the php server side after attaining the permanent session:

$this->fb = new Facebook($settings["api_key"], $settings["secret"], false, true);
$this->fb->user = $facebookUserId;
$this->fb->api_client->session_key = $sessionKey;
$this->fb->api_client->set_user($facebookUserId);
Les
A: 

The only other way to get a private users information is if you have an application and that user has given it access. Then you can snatch up any data using a FQL query.

$facebook->api_client->fql_query(
      "SELECT first_name, last_name, location
        FROM user
        WHERE uid={$userid}, 
        AND is_app_user;"
    );
Brandon G

related questions