Reputation: 3691
I'm having the toughest time figuring this out... how can I get the user ID? While I relize the question sounds a bit retarded, I can't find this anywhere! This is my following top part of my code:
require '../fb_fc/facebook-php-sdk-9147097/src/facebook.php';
$appId = 'APP_ID';
$appSecret = 'APP_SECERT';
$userId = 'USER_ID?????';
$userAccessToken = 'ACCESS_TOKEN';
How can I get the user ID? I get the access token by using $GET_['access_token'];
and this is the URL : http://friendsconnect.org/example.php?access_token=ACCESS_TOKEN_HERE#access_token=ACCESS_TOKEN_HERE&expires_in=0 (This is not a working link). How can I do this? I'm also new to this and am open to suggestions.
Upvotes: 0
Views: 4960
Reputation: 43816
From: https://github.com/facebook/php-sdk The minimum code to get the user ID (assuming a cookie has been set or the access token already passed in) is:
require 'php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
// Get User ID
$user = $facebook->getUser();
Upvotes: 5