I have downloaded the php sdk from github and put it on my server. My app is configured to use an iFrame. Using the following code, I repeatedly get 'no session' as my output meaning that the facebook object's getSession method is returning an empty object. Is there something wrong? I don't get any exceptions or errors.
<?php
require_once 'config.php';
$fbconfig['appId' ] = FACEBOOK_APPLICATION_ID;
$fbconfig['api' ] = FACEBOOK_API_KEY;
$fbconfig['secret'] = FACEBOOK_API_SECRET;
try{
require_once 'facebook-php-sdk-bdff088/src/facebook.php';
} catch(Exception $o){
d($o);
}
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => $fbconfig['appId'],
'secret' => $fbconfig['secret'],
'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.
try {
$session = $facebook->getSession();
} catch (Exception $e) {
d($e);
}
$fbme = null;
// Session based graph API call.
if ($session) {
try {
$uid = $facebook->getUser();
$fbme = $facebook->api('/me');
if (is_null($fbme)) {
die('fbme is null');
} else {
echo 'WE GOOD<br>';
var_dump($fbme);
echo '<br>';
}
} catch (FacebookApiException $e) {
echo 'exception caught<br>';
d($e);
}
} else {
die('no session');
}
echo 'all complete';
function d($d){
echo '<pre>';
print_r($d);
echo '</pre>';
}
?>
I have also tried setting the cookie param to 'false'.
Any help would be much appreciated. I had no problems getting the old SDK to work but this one just isn't doing anything.