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
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 .
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.
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'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.