简体   繁体   中英

How to store data from facebook to local variable?

Im using the SDK 3 by facebook, and to store the facebook id i am doing this:

$facebook_id = $user;

Which works a treat! However... i cannot access individual items in the array, like i remember with the previous SDK you could do:

$first_name = $me['first_name'];

However, i have tried that, and $user['first_name'] and stuff but getting no where! I cant find any documentation of this either on their dev website or on the internet :/

Many thanks. Ian.

Seems like $user is just the Facebook User ID that you get through the authentication flow. If you want to get user info, you need to make a separate Graph call, like so:

$res = $facebook->api('/me');
$first_name = $res['first_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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM