的JavaScript:
function referrerIsFacebookApp() {
if(document.referrer) {
return document.referrer.indexOf("facebook.com") !== -1;
}
return false;
}
if (!referrerIsFacebookApp()) {
top.location.replace("http://apps.facebook.com/APP_NAME_SPACE");
}
PHP:
function referrerIsFacebookApp() {
if (strpos($_SERVER['HTTP_REFERER'], "facebook.com") === false || strpos($_SERVER['HTTP_REFERER'], "facebook.com/l.php?u=") !== false) {
return false;
}
return true;
}
if (!referrerIsFacebookApp()) {
header("Location: http://apps.facebook.com/APP_NAME_SPACE");
}
看到這個線程。 http://stackoverflow.com/questions/6076359/force-facebook-app-to-use-page-tab-iframe – cpilko
問題是,FB.Canvas.getPageInfo只適用於apps.facebook.com/appname。外面時我無法使用它。任何建議? –