I wrote a tutorial about this a while ago.
The most important point is the “Site URL”:
Site URL: http://localhost/app_name/
Where the folder structure is something like:
app_name
¦ index.php
¦
+---canvas
¦ ¦ index.php
¦ ¦
¦ +---css
¦ main.css
¦ reset.css
¦
+---src
facebook.php
fb_ca_chain_bundle.crt
EDIT:
Kavya: how does the FB server recognize my localhost even without an IP or port??
I don’t think this has anything to do with Facebook, I guess since the iframe src
parameter is loaded from client-side it’ll treat your local URL as if you put it directly on your browser.
For example have a file on your online server with content (e.g. online.php
):
<iframe src="http://localhost/test.php" width="100%" height="100%">
<p>Not supported!</p>
</iframe>
And on your localhost root directory, have the file test.php
:
<?php echo "Hello from Localhost!"; ?>
Now visit http://your_domain.com/online.php
you will see your localhost file’s content!
This is why realtime subscriptions and deauthorize callbacks (just to mention) won’t work with localhost URLs! because Facebook will ping (send http requests) to these URLs but obviously Facebook server won’t translate those URLs to yours!