I thought this would be simple, but I can’t figure it out or find any relavent search results.
I have a Page Tab on my Facebook Page that loads a page from my server in an iframe. I want the page to only be served if Facebook is requesting it.
I’ve heard of looking at the User Agent, but that doesn’t work. With PHP at least… I think.
If I have to I’ll resort to redirecting with JavaScript, but that’s just sloppy.
Ideally it would look something like this;
<?php
...
if ( ! $is_facebook )
{
header("HTTP/1.1 404 Not Found");
}
?>
You could just check the signed_request parameter as described at http://developers.facebook.com/docs/authentication/signed_request/ . If you don’t need much security just checking for its presence should be enough. If you need more certainty you can decode it to verify it really came from Facebook.