I am trying to make a Facebook app and need user id from Facebook when the user opens the applicaiton. I have setup my application and its show mock form on the Facebook can
Download the PHP SDK
A very simple code example to get the user id - if the user is logged in and has authorised the application then $facebook->getUser() will give you the users id:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Get the user profile data you have permission to view
$user_profile = $facebook->api('/me');
echo "";
print_r($user_profile);
echo "";
} catch (FacebookApiException $e) {
$user = null;
}
} else {
die('');
}
Take a look a the examples within the SDK and on the Facebook Developers Site.