I have this test App as an iFrame in Facebook:
<?
require_once('src/facebook.php');
$config = array(
'appId' => '123',
'secret' => '123456',
'fileUpload' => true,
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
echo "[" . $user_id . "]<br>";
?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head></head>
<body>
<br>
<form action="" method="post"><input name="input" type="submit" value="Submit test"></form><br>
<a href="?hallo=1">Link test</a>
</body>
</html>
I use FaceBook PHP SDK version 3.1.1-25
What I see in IE 9: I vistit this app and it displays my user ID between brackets. But when I press the submit button or when I click on the link I re-enter the app and the user-id is 0.
Only in Chrome it seems to work fine, there it keeps displaying my user id like I would expect it to do.
What am I doing wrong, or else, how can i make a multi page app and use the user-id on the next page?
One Way is you can store user in SESSION
. Other way you can declare object of FACEBOOK
class as global in the page you want to use facebook object and you can call "$facebook->getUser()
".
global $facebook;
$user = $facebook->getUser();
echo $user;