$facebook->getSession() returns null in the example code. is that ok?

Posted by Toto on Stack Overflow See other posts from Stack Overflow or by Toto
Published on 2010-05-10T17:21:15Z Indexed on 2010/05/10 19:34 UTC
Read the original article Hit count: 1070

Filed under:
|

Running the example code for the Facebook API I get a null session object, and I should get a non-null object giving the comment in the code. What am I doing wrong?

In other words, in my index.php this fragment from the example code shows "no session" when I go to http://apps.facebook.com/my_app in my browser:

<?php

require './facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId' => '...', // actual value replaced by '...' for this post
  'secret' => '...', // actual value replaced by '...' for the post
  'cookie' => true,
));

// We may or may not have this data based on a $_GET or $_COOKIE based session.
//
// If we get a session here, it means we found a correctly signed session using
// the Application Secret only Facebook and the Application know. We dont know
// if it is still valid until we make an API call using the session. A session
// can become invalid if it has already expired (should not be getting the
// session back in this case) or if the user logged out of Facebook.
$session = $facebook->getSession();

if ($session) {
  echo "session ok";
}
else {
  echo "no session";
}


?>

Note: in my server index.php and facebook.php are in the same folder.

© Stack Overflow or respective owner

Related posts about facebook

Related posts about php