Create page to view through facebook app
I have created a facebook app i want my index.php file to be seen only through facebook app page and not to be seen by typing direct url of my domain .Right now the page is 开发者_C百科seen from both ends.
For eg:- if go to http://apps.facebook.com/myAppname/ i should see the content of my index.php but if i go through "http://mydomain/" it should be a blank page or should say not allowed . how do i implement the logical filters for the same.
You can use PHP to accomplish this:
<?
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("http://apps.facebook.com/myAppname/",$referrer)) {
header('Location: http://www.mydomain/index.php');
} else {
header('Location: http://www.mydomain/blank.php');
};
?>
Maybe try:
if ($_SERVER['HTTP_HOST'] == 'facebook.com'){
// Serve page
} else {
// Serve blank
}
精彩评论