Reputation: 11
I've created a FB app for a client succesfully. However, when I fist time load the app, it takes too much time retrieving users' profile in API
$user_profile = $facebook->api('/me');
In order to reduce the loading time in my page, I just wanna to get the specific fields I need. Is it possible, for example, get only 'username' or 'name' fields?
Thank you
Upvotes: 1
Views: 8220
Reputation: 161
You can retrieve user id in facebook by:
echo $user_profile['id'];
You can retrieve name by:
echo $user_profile['name'];
Retrieve user first name , last name or middle name:
echo $user_profile['first_name'];
echo $user_profile['last_name'];
echo $user_profile['middle_name'];
Retrieve user location name:
echo $user_profile['location']['name'];
Upvotes: 0
Reputation: 22973
Sure you can.
$user_profile = $facebook->api('/me?fields=name,username');
But I'm not sure it is going to be faster.
More fields can be found in the doc.
Upvotes: 6
Reputation: 14187
Well, you need to read some documentation
, there is a lot regarding PHP
and Facebook
.
To get the name
you can do the following:
$name = $user_profile['name'];
To get the username
will be easy too (I don't remember exactly what's the key
for the username
in that array
), but you can print
all the information from $user_profile
by doing the following:
print_r($user_profile);
or
var_dump($user_profile);
Then you can capture what you need doing the same way as above.
Upvotes: 0