NOTE: This is a facebook app which runs at page tab.
i have data.php file which gets all thing.
i get signed request with this following code:
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => false
));
$access_token = $facebook->getAccessToken();
$signedRequest = $facebook->getSignedRequest();
$user_id = $signedRequest['user_id'];
$liked = $signedRequest['page']['liked'];
In my index file i have some include action for fan or not fan and step php files.
Here is my index code:
require_once ('data.php');
if(isset($fid)){
if(isset($liked)){
$step = CHECK_STEP($fid);
if(isset($step)){
if($step == '1'){
include('fan-step1.php');
}
if($step == '2'){
include('fan-step2.php');
}
if($step == '3'){
include('fan-step3.php');
}
if($step == '4'){
include('fan-step4.php');
}
} else {
include('fan.php');
}
} else {
include('notfan.php');
}
} else {
if(isset($liked)){
include('fan.php');
} else {
include('notfan.php');
}
}
i’m using ajax in step php files to update database for step check. if ajax action complete, action reflesh the page. Code:
success: function(){
window.location = window.location.pathname;
}
after refreshing the page index file or data file cant get the page liked request. then if i refresh the page manual (ctrl+F5). It get the request and include next step php file.
What is wrong? why it cant get the liked request after js refresh?
With your redirection, you refresh your iframe. The signed request of facebook however, is sent via POST to your iframe. So if you just refresh your iframe, the signed request will not be sent again, since the second request (after the refresh), the request is not performed by facebook, but from within your application.
Reload the complete page (facebook + your tab) instead, using
top.location.