开发者

How to get user details using facebook connect

开发者 https://www.devze.com 2022-12-09 00:54 出处:网络
How can I get firstname and last name of facebook user while using f开发者_如何学Python-connect?

How can I get firstname and last name of facebook user while using f开发者_如何学Python-connect?

I can login using api, but I couldn't get firstname and lastname of logged in user.


You have to invoke users.getInfo. In PHP, you would do it like this:

$userId = 1234567;
$fb = new Facebook(FACEBOOK_API_KEY, FACEBOOK_SECRET);
$fb->api_client->users_getInfo($userId, 'name, pic_square, first_name');

You can check the function's documentation here.


$client = new FacebookRestClient(API_KEY, SECRET_KEY, SESSION_KEY);
$userinfo = $client->users_getInfo($client->users_getLoggedInUser(), array('first_name','last_name'));
echo $userinfo[0]['first_name'] . ' ' . $userinfo[0]['last_name'];
0

精彩评论

暂无评论...
验证码 换一张
取 消