$ signed_request = $ facebook-> getSignedRequest();

时间:2012-08-16 07:39:47

标签: php facebook-like facebook-iframe

我尝试通过singed_request为我的脸书粉丝页面制作粉丝门内容。代码工作完美,但我不想在iframe中重定向,我需要在用户点击LIKE到另一个页面后重定向。如何删除iframe并插入重定向?

这是我的代码:

<?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\">"; } }
?>

1 个答案:

答案 0 :(得分:1)

只有在代码

之前没有任何输出时才会有效
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\">";
    }
}