i’m trying to prepare an application for Facebook. application software is created. “localhost” tests without any problems but links within the Facebook application is not working… e.g. “page.php?page=test“… application, using the fan page. the first page is opened, UserID and PageID data is seamlessly but i click the link to the sample, the data is blank. i tried to target=”_top” but not work…
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => false,
));
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$m2_facebook_kullanici_id = $data['user_id'];
$m2_facebook_sayfa_id = $data['page']['id'];
if(empty($_GET['sayfa'])){
...working here USERID and PAGEID...
}
if($_GET['sayfa'] == 'guncelle'){
...does not work here USERID and PAGEID...
}
i wonder what’s wrong?
thank you…
basic solved:
<?php
require 'facebook.php';
$signed_request = $_REQUEST["signed_request"];
$facebook = new Facebook(array(
'appId' => 'xxx',
'secret' => 'xxx',
'cookie' => false,
));
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$m2_facebook_kullanici_id = $data['user_id'];
$m2_facebook_sayfa_id = $data['page']['id'];
setcookie("facebook_user_id", $m2_facebook_kullanici_id);
setcookie("facebook_page_id", $m2_facebook_sayfa_id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>
<body>
<?php
if(empty($_GET['sayfa'])){
echo '<a href="index.php?sayfa=guncelle">Güncelle</a><br />';
echo '<h3>Home Page</h3>';
echo '<strong>User ID:</strong> ' . $m2_facebook_kullanici_id . '<br />';
echo '<strong>Page ID:</strong> ' . $m2_facebook_sayfa_id;
}
if($_GET['sayfa'] == 'guncelle'){
$m2_facebook_kullanici_id = $_COOKIE["facebook_user_id"];
$m2_facebook_sayfa_id = $_COOKIE["facebook_page_id"];
echo '<a href="index.php">Back</a><br />';
echo '<h3>Settings Page</h3>';
echo '<strong>User ID:</strong> ' . $m2_facebook_kullanici_id . '<br />';
echo '<strong>Page ID:</strong> ' . $m2_facebook_sayfa_id;
}
?>
</body>
</html>
SOLUTION:
just add the following code to the end of links
or
a simple example of the application
special thank: moguzalp and Mesut Eyrice