$ facebook.getUser(); 一直回来0

I'm posting here due to a problem with php and the sdk of facebook.

For a reason I don't really know, when I try to get the userID of the logged account, continuously I received the same value, 0, even if i'm logged.

I've been trying to debug some variables, $facebook, checking sessions, etc. but with unsuccessfully results, then i'm gonna step by detailing all what i'm doing and the debug log i'm doing:

I'm using hostinger servers, that hosts my website. Due to i've found many problems, i've created a test webpage in which i have 5 files: index.php

callback.php
facebook.php (comes from facebook)
base_facebook.php
certificate

The code i have on index.php is what i've pasted here: [index.php]: http://pastebin.com/Mfdkxz8H This is only the first part of the code which tries to get the autentification.

The code i have on callback.php is what i've pasted here: [callback.php]: http://pastebin.com/Uw0A3NM8. There i try to get the userID.

I've read some post and for some reasons there were so many cases in which the token wasn't received in the second file/call.

I don't really know what the problem is and would be happy to find a solution.

P.D It doesn't matter the appId and secret because facebook and webpage were created for a test.

Hard to tell what is going up from your code example (By the way, you should NEVER post your appId and secret in public like that otherwise someone will be able to compromise your application). A gave your code a quick glance and it "looks" fine but here are a couple of pointers:

But here are a couple of pointers. 1) Make sure you have the latest version of the Facebook SDK (assuming you do) 2) For SANITY sake, i would keep your Facebook API files in its their folder ('sdk') 3) DOUBLE CHECK your app settings to make sure the appID and secret are correct (I have made this mistake many times), also make sure that your at is NOT in sandbox mode 4) Then try something like this

include_once("sdk/facebook.php");

//Call Facebook API
$facebook = new Facebook(array(
  'appId'  => XXXXXXXXXXXXXXXX,
  'secret' => XXXXXXXXXXXXXXXX,
  'cookie' => true, // enable optional cookie support
));

$params = array(
  'scope' => 'email',
  'redirect_uri' => 'http://devstarlight.esy.es/facebook/callback.php'
);

$login_url = $facebook->getLoginUrl($params);