0

I tried to build facebook game but I stuck in saving score.

I have tried exactly as written in http://developers.facebook.com/docs/guides/games/getting-started/#step4 but It just simply wouldn't save the score.

I thought the problem is in this listing :

$facebook = new Facebook(array(
      'appId' => $app_id,
      'secret' => $app_secret,
    ));

  $user = $facebook->getUser();
  print('user : '.$user.' ');

there is always 0 although my fb account had logged in. With this problem I couldn't save nor update the high score. I need help to find the way to retrieve the $user.

I really appreciate every favor to me. Thank you...

  • This means the user hasn't authorized the app. You should detect this case and redirect the user to the [OAuth dialog](http://developers.facebook.com/docs/reference/dialogs/oauth/). – David Schwartz May 07 '12 at 10:51

1 Answers1

0

Do you have this part?

// If the user has not installed the app, redirect them to the Auth Dialog
   if (!$user) {
     $loginUrl = $facebook->getLoginUrl(array(
       'scope' => $scope,
       'redirect_uri' => $app_url,
     ));

     print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
   }

Its required to log user and get his data.

Here is good explanation http://developers.facebook.com/docs/authentication/server-side/

Artur Michalak
  • 459
  • 3
  • 6