I have this HTML on this URL: https://myapp.herokuapp.com
<html>
<body>
<iframe frameborder=0 border=0 scrolling="no" src="<?php echo $_GET['url']; ?>" width="760px" height="521px"></iframe>
</body>
</html>
I have created a Facebook Page Tab and I want that anyone can install it on their Facebook Page with a different URL. So when you click on the tab on FB Page 1 it would display embedded URL1, FB Page 2 would display URL2, and so on. The URL is, then, a parameter when you install the Page Tab.
I have tried this:
https://www.facebook.com/dialog/pagetab?app_id=XXXXXXXXXX&next=https://myapp.herokuapp.com?url=HERE_YOUR_URL
It is installing the app, but seems that the URL parameter in the iframe is null. What am I doing wrong?
Thanks
My approach is a little different.
While it may not be possible to install Apps with URL parameters, you could adjust their content depending on which Page loaded them in the first place. As the Page Tab Facebook API Integration Tutorial states:
When a user selects your Page Tab, you will receive the signed_request parameter with one additional parameter, page. This parameter contains a JSON object with an id (the page id of the current page) (SOURCE)
So you would install the same App on several pages, and use the following code at the top (after you've created the $facebook
object):
$page_id = "";
$sr = $facebook->getSignedRequest();
if($page = $sr['page']) {
$page_id = $page['id'];
}
You should now be able to use $page_id
as the unique identifier telling you which page the user is currently viewing the application from, instead of a $_GET
variable. Switch
statements or a database integration are the first methods that come to mind, but you seem to be asking how to identify and retrieve a unique parameter and not how to use it, so I'm sure you will figure this out on your own. :)
Note: This (obviously) will not work on an app being installed on several Page Tabs of the same page, but that doesn't seem to be a concern of yours.