-1

im try to make a fan gate content for my facebook fan page by singed_request. The code work perfectly but i don't want redirect in iframe, i need redirect after the user click LIKE to another page. How i can remove iframe and insert a redirect?

this is my code:

<?php
require_once('facebook.php');
$app_id = "id";
$app_secret = "secret";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
function parsePageSignedRequest() { if (isset($_REQUEST['signed_request'])) {     $encoded_sig = null; $payload = null; list($encoded_sig, $payload) = explode('.',     $_REQUEST['signed_request'], 2); $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));     $data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true)); return     $data; } >return false; } if($signed_request = parsePageSignedRequest()) {     if($signed_request->page->liked) { echo "<iframe allowtransparency=\"true\"     frameborder=\"0\" SCROLLING=\"YES\" style=\"width: 800px; height: 1000px;\"     src=\"http://onlyimagination.com/dm3theme2\" id=\"any_name\" name=\"anyname\"><iframe>";
} else { echo "<img src=\"http://www.onlyimagination.com/facebook/crazyvideo/img.jpg\"     width=\"582\" height=\"487\">"; } }
?>
j0k
  • 22,600
  • 28
  • 79
  • 90

1 Answers1

1

This will only work if don't have any output before your code

if ($signed_request = parsePageSignedRequest()) {
    if ($signed_request->page->liked) {
        header('Location: http://onlyimagination.com/dm3theme2');
    } else {
        echo "<img src=\"http://www.onlyimagination.com/facebook/crazyvideo/img.jpg\"     width=\"582\" height=\"487\">";
    }
}
xCander
  • 1,338
  • 8
  • 16
  • Sorry. I don't consider that being me helping you to learn about PHP programming. You could always hire a consultant if you have no interest in learning this stuff your self. – xCander Aug 16 '12 at 08:01
  • What I have done in my code is replacing the output of an iframe with a header call (http://se.php.net/manual/en/function.header.php), sending the visitor to a new URL. – xCander Aug 16 '12 at 08:03
  • Sorry, I that's to hard to read, update your question. What error do you get? – xCander Aug 16 '12 at 08:08
  • you should be carefull with having you app id and app secret here – Pavenhimself Nov 16 '12 at 12:12