views:

136

answers:

1

Hi,

I have written a small piece to get the user to login :

 <?php

include_once ('facebook.php');
  $api_key = 'xxxxxxxxxxxxx';
  $secret  = 'xxxxxxxxxxxxx';
  global $facebook;
  $facebook = new Facebook($api_key, $secret);
  $facebook->require_frame();

#Ask user to login if not logged in
$is_tab = isset($_POST['fb_sig_in_profile_tab']);
if( !$is_tab ){
    $uid = $facebook->require_login($required_permissions = 'email,status_update,offline_access');
}
else{
    $uid = $facebook->get_profile_user();
}

I need to retrieve the users info once I have the uid. Unfortunately I cannot find the api calls for it and there is a no IDE for facebook :(. Can anyone point me to the api's or give me here. I want to get users username, city, zipcode.

I coudnt get this to work : facebook.Schema.user user = api.users.getInfo();
I think it is for the new API lib.

Thanks.

P.S: I am not using graph APIs, because I found them to be poorly documented and I got stuck with them for a while so decided to abandon them atleast for now.

+1  A: 

You can get it like this:

$user_info = $facebook->api_client->users_getInfo($uid, "name, city, zipcode");
print_r($user_info);

More Info:

Sarfraz
Thnx Sarfraz for answering yet one more of my question. I get the following info when I try to print the array: ( [0] => Array ( [first_name] => [uid] => 1 ) )Also, if I try running it on the test console:{ "error_code": 101, "error_msg": "Invalid API key", "request_args": [ { "key": "uids", "value": "xxxxxxxxx" }, { "key": "fields", "value": "first_name" }, { "key": "method", "value": "users.getInfo" }, { "key": "access_token", "value": "" }, { "key": "format", "value": "json" } }
p1
@p1: Make sure that you are specifying the correct your app API key which can be seen from developer settings eg http://www.facebook.com/developers/ and then go to your app and note that api key, currently you are specifying `755860a0428dbb7abc767458a0fd6ea3`
Sarfraz
Hello Sarfraz: I checked the API key and the secret keys are correct. The second error [Invalid API key] is from the test console which you gave me [http://developers.facebook.com/docs/reference/rest/users.getInfo ]. However on the shell console the output I get is after doing php filename.php I get: top.location.href = "http://www.facebook.com/login.php?api_key=XXXXXXXXXXXXXXXIf I access the file from browser I get : helloArray ( [0] => Array ( [first_name] => [uid] => 1 ) )
p1

related questions