Take the 2-minute tour ×

i recently made a test app in facebook, the app is a website app and i only need user login so that i can access user info from within the app using the php sdk, when i first tested it, the login process works perfectly, the problem is, when i reach the test page, it is completely blank, whereas i expect it to echo: HELLO NAME, where "NAME" would be my name, here's the code, i won't post the app id, secret,etc, as those certainly work, due to the login process being fine:

   $app_id = "xxxxxxxxxxxx";
   $app_secret = "xxxxxxxxxxxxxxxxxxxxxx";
   $my_url = "http://www.anithro.com/anithroproject/login.php/";
    $code = $_REQUEST["code"];

   if(empty($code)) {
 // Redirect to Login Dialog
 $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
   . $_SESSION['state'] . "&scope=user_birthday,read_stream";

   if($_SESSION['state'] && ($_SESSION['state'] === $_REQUEST['state'])) {
 // state variable matches

 $response = file_get_contents($token_url);
 $params = null;
 parse_str($response, $params);
 $_SESSION['access_token'] = $params['access_token'];
   . $_SESSION['access_token'];

 $user = json_decode(file_get_contents($graph_url));
   else {
     echo("The state does not match. You may be a victim of CSRF.");

i have followed the code to the letter, why can't i access the user variables?thanks in advance.you can try visiting the url i've given and see, it's just blank.

share|improve this question
Are you getting any PHP errors? Looks to me like you are getting a PHP error that causes the code to stop executing. –  Jabe Nov 15 '12 at 8:55
add comment

1 Answer

up vote 0 down vote accepted

Did you test the access_token you are using if it is authenticated? You can use this for debugging tools: https://developers.facebook.com/tools/

You can also try this link: https://github.com/facebook/facebook-php-sdk The PHP SDK here uses a class to get the basic info of the user that logs in. Check the example folder.

share|improve this answer
yes i did, it is aunthenticated, i just want to now why nothing is printed at all using this example, i've even added code to echo random stuff after the echo ("Hello".$user->name); but nothing gets echoed, when i do add html under all that php, it does get printed, and if i add php outside the above block of code, it get's printed as well. –  gumper Nov 15 '12 at 10:07
ok, i was wrong, no php gets printed at all whenever i want it to, only html stuff. –  gumper Nov 15 '12 at 10:20
try to var_dump($user); and it will return all the value of the $user, if it is what you expected or not. –  Rei Nov 15 '12 at 10:26
nothing happens, nothing gets printed, do you have an alternative way of loging in a user that you would recommend, but that would still allow me to access his/her data using the php sdk, you know like this: $userdata=$facebook->api('/me'); and $frienddata=$facebook->api(array( 'method' => 'fql.query', 'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1' ));? –  gumper Nov 15 '12 at 10:38
Then that only means that you have a problem with your script. Did this app have the Website URL? and the domain name? in the developer.facebook.com? I will try to give you a sample code. –  Rei Nov 15 '12 at 10:47
show 2 more comments

Your Answer


