How to get the Facebook iFrame Tab url (including parameters) from within the app? - facebook

I think there are a few similar questions that seem to suggest using app_data in the signed request (http://developers.facebook.com/docs/authentication/signed_request/) but I'm not sure if it will be possible to do what I am trying to achieve with it as I've never used it before.
If I have my Facebook 'Tab' Url as follows:
http://www.facebook.com/pages/PAGE_TITLE/PAGE_ID?sk=app_APP_ID
What I want to do is add an extra parameter on the end as follows:
&WT.mc_id=email-uk-8014
The reason for this is for tracking purposes and links will be sent out of the form
http://www.facebook.com/pages/PAGE_TITLE/PAGE_ID?sk=app_APP_ID&WT.mc_id=email-uk-8014
and the extra parameter will allow us to track the campaign id.
As you can see I have no way of knowing the value of the parameter beforehand as it depends on the link clicked by the user so is it possible to somehow get the value of the WT.mc_id parameter inside my iframe app?

app_data is the only parameter passed through other than the page ID and user's basic details (locale and if they do/don't like the page) - you'll need to use that for any sort of campaign tracking (or link elsewhere and redirect to the tab after capturing your analytics data)

you can pass get variables in facebook but only in canvas application
you just have to use $_REQUEST['xxx'] to retrieve the data.

you should not pass the param in href of facebook. Instead just make linking inside your app so that you can track the events. As you will be in iframe and having complete control you can do same on your own site.

Related

displaying own like count next to like button

I have a website where the URLs have some tracking parameters that do not affect the page that is displayed i.e. the URL is of the form http://mywebsite.com/page1?tracking1=aaa&tracking2=bbb and 'tracking1' and 'tracking2' are just tracking parameters used for some other purpose and do no determine the page that is displayed. The page that is displayed is always 'http://mywebsite.com/page1' irrespective of the values of these tracking parameters.
I have included the facebook like button on my website pages and facebook treats each of these URLs, including the tracking parameters, as separate pages. I'm not able to get facebook to ignore these tracking parameters and just consider the URL without tracking parameters as a page. So, I'm storing my own like count against the actual URL (when I get a callback on the like action) and displaying it next to the like button.
Is displaying own like count next to facebook like button against their usage policy? Is there a better way to do this?
Is there any particular functional reason you're using GET (ie URL) variables to store your tracking?
If you can push them into POST instead, or use cookies or sessions for your tracking, you can simplify your URLs and Facebook should treat it as a single page.
If you have to use GET due to, for example, the links coming from external websites, you could use a pass-through URL to do your tracking, before forwarding to the main page. ie someone clicks the link to redirect?tracking1=aaa&tracking2=bbb&page=page1
And redirect, as you may have guessed, does what you need to do with your tracking before forwarding the user on to page1.

Callback from Facebook app as a tab app on multiple pages

Salon owners can create an account with their salon information on our platform and they get a page that they can use as a tab app.
I want to be able to serve all these pages from one app instead of having to install each one seprately and I also want to make the life of the salon owner easier by helping them to install the tab.
I know about the link I can create to help them install the app and I know that when a visitor visits the app that facebook will send the page ID. So far so good.
https://developers.facebook.com/docs/appsonfacebook/pagetabs/
But how do I make sure that when the salonowner follows the link to install the app that I get the page ID back (through callback or other) so that I can register which page ID belongs to which salon account.
I've read sone 2011 article about a callback but I can't find any recent info on this.
I think it should be possible as a lot of sites offer easy fb apps to businesses.
Any help would be welcome!
EDIT: Could this last piece of info in the Facebook link above be used to do this? I don't quite get it yet.
In addition, your app will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on. It could look like this: "https://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here". You can use that to customize the content you render if you control the generation of the link.
Well... Preventing users from adding your application to their page is impossible. You can't prevent that.
What you will be able to do is to detect who has added your application and according to that, change the content (or not display it at all). So you'll have to start with a list of "allowed" page_ids to match to the accounts you want.
Your application will receive a signed_request each time a user arrives at your application (within a page). Inside that signed_request is information not only on the user but also on the page that the application is on (provided it is a page tab app).
Once you have obtained the signed_request, it will hold a page key which contains:
A JSON object containing the page id string, the liked boolean (set to
true if the user has liked the page, false if not) and the admin
boolean (set to true if the user is an admin of the page, false if
they're not). This field is only present if your app is being loaded
within a Page Tab.
So you'll be able to access the page_id from within this variable and make a decision on the type of content you want to be displayed.
Ok, after running some tests I found out that when you add a URL as 'next' parameter to the install URL Facebook will send the admin(user) back to this URL while adding an array to the request containing all the page Id's the app was installed to.
Like this: YOUR_CALLBACK_URL?tabs_added[ID]=1
Proved to be quite easy in the end

passing variables into new page tab installations

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

Facebook App Setup

I created FB application that use iframes, and it's working okay, as it should, BUT I need to check from what page is calling it.
I want different pages to pass different variables to that iframe location.
I already know how to set up it to three levels ( original page, application page, and on tab page, with different display content ), but I need to check from what page it's called.
I am thinking that it can be done in 2 ways:
1 way: Find way to pass specific variable based on page that is using this application as tab, and then redirect it to right location
2 way: Find way to create new application outside facebook ( maybe API or something ) and then enter all those values including: App name, app link that have this variable included, app tab link, using iframe and not FBML...
I will love to use 2. way...
I'm not asking you to show me code, I know that I need to do my job, I'm not asking you to do it for me, I'm just asking for help, for directions from someone who already create something like this, to point me to right direction where can I find way...
Also, please don't tell me to read bunch of stuffs, like FB Documentation or whole book that have all other "not-used-here" stuffs, I need specific part where there is a word about this...
If someone know anything about this, write it here...
Thank you!
The "page" parameter is passed along within the "new" signed_request parameter on (iframe) tabs. You get what you need for "free" ;)
page: A JSON object containing the page
id string, the liked boolean if the
user has liked the page, the admin
boolean if the user is an admin. Only
available if your app is an iframe
loaded in a Page tab.
http://developers.facebook.com/docs/authentication/signed_request/

Passing php variables to Facebook Application Tab

Are you able to send php variables to a application in a tab (in facebook)?
I have built a system which sends a wall post to a friend, which includes a link with a php variable in it. This variable needs to be processed by the app, but I cant work out how to (or if I can) do this.
Yes, you can pass URL Parameters to an iFrame Tab App.
Pass the parameter: http://www.facebook.com/MyPage?sk=MyApp&app_data=any_string_here
Receive the parameter: $app_data = $signed_request["app_data"];
See more:
http://forum.developers.facebook.net/viewtopic.php?id=92661
I think this is a duplicate of the following question:
Facebook Application Tab -> External Linking with PHP
It does not seem to be possible to pass URL parameters into a Facebook application that is in a Tab. You can do it on the Application page however.
Edit: as per the answer below, this behaviour has changed. Details here: http://forum.developers.facebook.net/viewtopic.php?id=92661