[英]Get specific fields on user profile. Facebook SDK PHP
I've created a FB app for a client succesfully. 我已经成功为客户端创建了FB应用。 However, when I fist time load the app, it takes too much time retrieving users' profile in API
但是,当我第一时间加载应用程序时,在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 谢谢
Well, you need to read some documentation
, there is a lot regarding PHP
and Facebook
. 好吧,您需要阅读一些
documentation
,有关PHP
和Facebook
的内容很多。
To get the name
you can do the following: 要获取
name
您可以执行以下操作:
$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: 获取
username
也很容易( 我不记得确切的username
是该array
username
的key
),但是您可以通过执行以下操作来print
$user_profile
的所有信息:
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: 您可以通过以下方式在Facebook中检索用户ID:
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'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.