I looked at the source code in the browser facebbok create a form over it within the code and this
<form method="post" id="proxy_form"> <input type="hidden" autocomplete="off" id="signed_request" name="signed_request" /> </ form> <script> document.domain = "facebook . to ";
FrameName window.location.href.split var = ('#') [1];
submitForm function (appTabUrl, signedRequest) {
var proxyForm = document.getElementById ("proxy_form");
proxyForm.setAttribute ("action", appTabUrl);
proxyForm.setAttribute ("target", FrameName);
var input = document.getElementById ("signed_request");
input.setAttribute ("value", signedRequest);
proxyForm.submit ();
}
waitForParams function () {
if (parent.PlatformAppController &&
parent.PlatformAppController.getFrameParams (FrameName) &&
document.getElementById ("proxy_form") &&
document.getElementById ("signed_request")) {
var params =
parent.PlatformAppController.getFrameParams (FrameName);
submitForm (params.appTabUrl, params.signedRequest);
Else {}
setTimeout (waitForParams, 10);
}
}
waitForParams (); </ script> <div <noscript> class="pam uiBoxGray"> You need to enable Javascript in your browser to use Facebook Applications. </ div> </ noscript>
my javascript is enabled and I I tested 3 different machines
I had this code and it didn't work (only for fans) in Chrome either. For non fans it displayed the image correctly.
I just changed my redirects to a HTTPS and it has worked! :) It looks like Chrome has issues with redirects to http. Just add an "s" to all of your links and it should work.
Be aware of hidden redirects, if you have a parameter URL or something like that, there you need to add the "s" twice: at the beginning (https://www.myweb.com/r.php?
) and in the middle (&url=https%3A//www.myweb.es
)
hope it helps!
An example:
<?php
require 'facebook.php';
$app_id = "384609344916003";
$app_secret = "f615dfb4c787d05d5f1a2fbefd11cadc";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];
if ($like_status) {
if ($page_id == '1234567890'){
// UK
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.myweb.com/fbpromo/");
exit();
}
}
else {
echo "<link type='text/css' rel='stylesheet' href='facebook_new.css'/>";
echo "<body>";
if ($page_id == '1234567890'){
//English
echo "<img src='http://www.myweb.com/img/facebook/FB-app-non-fans.jpg' alt='Like us' /> ";
}
}
echo "</body>";
?>