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.
From my understanding it's not possible to have on app installed in separate Page tabs. You'll need to create different apps for that, but you can use use the same "base app" location and augment the location with your desired parameters.
For example:
You create two apps with "Page Tab" as platform.
For the first app, specify a Page Tab URL https://myapp.herokuapp.com/index.php?test=1
For the first app, specify a Page Tab URL https://myapp.herokuapp.com/index.php?test=2
Create an index.php in your apps base folder:
<? echo $_GET["test"]; ?>
Add both Page Tab apps to a Page (or separate Pages). See: https://developers.facebook.com/docs/graph-api/reference/v2.0/page/tabs/#publish or https://developers.facebook.com/docs/reference/dialogs/add_to_page/
Open first Page Tab, then second, and see that diffent parameter results are shown
Related
I would like to build a customized Facebook page tab for other page owners to instal onto their Facebook pages. Each page tab will need to have its own ID in the links that lead out of the page tab in order for us to track that page activity.
For example each page tab will have a list of products that link to the relevant product pages on an external website. Each of those links will have a unique ID parameter to we can track clicks and purchases. [e.g http://www.mydomain.com/products/product123.aspx?userid=12345]
So I need to create the userid variable in the link. Possibly using GET (or Request.QueryString for asp) to receive from the initial page tab installation.
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs
[https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
I thought that this will pass the userid over to the new page tab, but it doesnt seem to work.
If anyone could point me in the right direction i would be very grateful.
Cheers
From what i can see I might be able to use the app_data parameter to pass data over to the page, but when i tried it, it didn't work.
This is what i am using to install the page tabs [https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&app_data=12345]
But you are aware, that appending &app_data=12345 does not mean you will get a GET parameter by the name 'app_data', right …?
The app_data will be passed as a property inside the signed_request parameter – so you’ll have to decode that one, and inside you’ll find your app_data value.
Why does 'each page tab' need to have an ID?
The Page ID should be enough for you to determine which content to show (and it's passed to your app on each page load via the signed_request, and the page ID is also passed back to your app in the callback to the pagetab dialog
You could also request manage_pages Permission from the user to determine the list of pages they administer and if your app is installed on each
I want to create a simple facebook page tab. Where i want that, if a user install this app to a page the page id will be stored in my database. Then i will show different content for individual fb pages. I read some documents where it is mentioned that signed_request could be used to get the page id. but signed request it received after the page is loaded into some fb page.
As anyone can install my app it is not possible to know who is going to install the next. but i have a plan to show different pages(from my server) in different page (in Facebook) tabs.
Just noticed that it is now an array, named tabs_added . The key of the array is the page ID and the valude is 1 (true) for tabs added. This would give you the idea that the other page ID keys would be in the array with 0 (false), but they are not passed.
<?
// grab all keys in an array
$aKeys = array_keys($_REQUEST['tabs_added']);
// take the first key - this is one of the page ID's the tab was added to
$sFirstKey = array_shift($aKeys);
?>
Courtesy dk1, precisely $_REQUEST['fb_page_id'] made it work.
Facebook will call your Application URL when someone is installing you app as a page tab. Do there some $_REQUEST logging to find out which params Facebook is sending in that case. There is one value that identifies the page where the application got added.
I've done this already but have no sample code here atm to show you.
My goal is that have a fb page app (only in one tab) and use it with linkable subpages inside it.
For example:
If I click on subpage link there would be a http or ajax request inside the iframe. Thats fine, i can do that.
BUT
in the solution I also want to implement these two features:
1.:
I want that page to be accessible directly from an url like:
http://facebook.com/pagename/app..blabla/subpage1
or
http://facebook.com/pagename/app..blabla&sk=535&subpage=1
or
http://facebook.com/pagename/app..blabla#subpage1
2.:
On subpage link click inside iframe I want the browser url to turn into something like mentioned in the 1. point. (even when using ajax - probably with a hash tag)
Is it possible?
If you look at the page tab tutorial http://developers.facebook.com/docs/appsonfacebook/pagetabs/ at the bottom of the page they describe how you can create the 'subpage' idea using the app_data parameter. So your links will look like http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here
For your second question, in the links on the page you would specify target="_top" in any links you have with the href being: http://www.facebook.com/YourPage?v=app_1234567890&app_data=subpage1. This will cause the entire page tab to load through Facebook and you'll get the signed_request and your app_data parameters.
You probably don't want your ajax to load through facebook, because you'll get the Facebook page back instead of json or whatever you are trying to load. Instead you'll just make ajax calls to your server and pass the parameters you need to, like app_data or whatever you want.
Facebook provides us with an option to choose a custom landing tab for the new visitors (i.e. non-fans). Can we have a custom Landing tab for fans so that every time i open the page, i m directed to that custom page rather than the Wall..
Have you checked Facebook Help Center?
How can I select a tab as default for people who already Like my Page?
This functionality does not exist.
What you are trying to do is straightforwrd.
Create a "landing page" tab app and add it to your page. Here is a tutorial on how to do it: http://how-to-create-facebook-app.koliber.com
Make this tab the default for your app. On your page, in the upper-right corner click "Edit Page" and change the "Default Landing Tab" to the one you would like displayed by default.
Now everyone will be shown the default tab when they log in. How to distinguish between those visitors who "liked" your page and those that didn't? Easy. Make two versions of the page and display one to those who liked and one to those who didn't like. How to find out whether the current visitor liked your page or not follows:
When your Page Tab URL is called in the iframe, it is passed a signed_request POST parameter. This parameter contains the info you need. However, it is encoded and structured so it needs some processing to get the info
Split the signed_request on the '.' character. The first part is the signature. The second part is the encoded_data
Decode the encoded_data into a JSON string using the URLBase64Decode function equivalent in your server-side programming language
The JSON object contains a node called "page". This contains a node called "liked".
If "liked" is true, the user liked the page and you display the "liked" version of your app. If false, show the "Please like me" version of the site.
This way, when visitors visit your page, they see your custom app in a tab. The actual content is determined server-side on your server based on the page.liked property inside of the JSON object passed to you in signed_request
The simple answer as far as I have been able to find out is "No". There is no setting which aligns with this requirement.
The wall is the default tab for people who like the page.
http://apps.facebook.com/static_html_plus/ this application gives you those options... enjoy!
<iframe src='http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.example.com&layout=standard&show_faces=false&width=100&action=like&colorscheme=light&height=35' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:100px; height:35px;' allowTransparency='true'></iframe>
or:
<script src='http://connect.facebook.net/en_US/all.js#xfbml=1'></script><fb:like href='http://www.example.com' show_faces='false' width='100'></fb:like>
I have media files that are loaded dynamically onto a page.
After the file is loaded, I want to put out a Facebook Like button for it so that the text that appears in the Facebook News Feed is specific to the media item.
At the moment it always describes the page itself.
In the developer docs it says to do this you need to set Open Graph info in the page HEAD section.
I don't see how that would work with the multiple media items I'm dealing with.
Create a new page for each media item (as a parameter to a script) so that FB indexes each individually:
<fb:like href='http://www.example.com/fblike.php?item=name_id_url_whatever' show_faces='false' width='100'></fb:like>
Where fblike.php redirects back to the main example.com or whatever page the media item in question is on. You'll probably need some sort of database to track it, unless everything links back to the main page.