Load specific page after Application outh redirect - facebook

So, I am using https://www.facebook.com/dialog/oauth?client_id=xxxx&scope=email&redirect_uri=xx to allow me access to users' details.
I want to then direct users to the app, and load specific page within my tab. This is where I become stuck...
My tab URL is in the following format:
http://www.facebook.com/pages/mysite/xxxx?sk=app_xxx
Is there something I can to this URL to make it load a specific URL?
(the app is always in the tab)
Thanks!

To define which page you want your tab to load you can use an additional parameter called app_data in the url to your tab, eg
http://www.facebook.com/MY_PAGE?sk=app_MY_APP_ID&app_data=A_STRING_OF_DATA
Your tab will then receive this as part of the signed_request, you can grab it and use it to work out which page your tab needs to display.

Related

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

Unique content for each instance of a page app?

So I have a canvas app that allows a user to create content to be displayed in a page tab. User input is saved in an xml file. The xml file is named with the userid, example: 12345678.xml.
I also have a page app that uses PHP simpleXML to load and display content from the xml file
So, if I created content via the canvas app, I can create a page tab app and point it at MYPAGEAPPDOMAIN/index.php?uid=12345678 and use the passed uid variable to load the proper xml file, and display the content I created under that uid. I've tested all this and it works fine.
The problem is, that each user would have to manually create their own page tab app, with the url containing their user id to display the correct content. I could provide instructions and say "here's how your url should look" but I'd really like to simply let them click "add this to my page."
As far as I can tell from other questions I've found, everyone who adds the page will display content from the url specified in the page app basic settings. So there's no way to have Jim's iframe load index.php?uid=12345678 and Jenny's iframe load index.php?uid=87654321.
Is there any way, when a page tab is loaded, to get the user id of the person who installed it? (Get the admin ID for the page?)
Or is there any other way to let each instance of my page tab app display the proper content for it's location?

handle subpages inside facebook app (with one single tab)

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 SDK install APP with install confirmation

I am looking for help to validate when a Facebook APP has been installed. I am currently using PHP SDK to have the clients sign in and in the same manor I would like for them to return to the site once the APP is completed and installed correctly.
Is there a method to use this link and have it return with the client id?
https://www.facebook.com/add.php?api_key=XXX
You should not use https://www.facebook.com/add.php?api_key=XXX for any cases other addition of application to page as a tab (and even this is undocumented).
If you're using PHP-SDK you should use Facebook::getLoginUrl to log user in, which support redirect_uri parameter so you can add client id as argument to this URL
Update:.
As it turns question is about adding application tab to page you should be using Add Page Tab Dialog to provide user with a way of "installing" application to page without leaving your app.
You can refer to answers on How to add tab application to a page with the "new auth dialog" for more info.
Update 2:
How to reach applications running as Page Tab described in "Integration with Facebook APIs" section of Page Tab Tutorial:
your application 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. For the Shop Now link above, that could look like this: http://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.
You not required to add app_data, just use v=app_APPID to link to your page tabs (Facebook itself using sk instead of v, both works).

Facebook: Run a page with multiple application tabs of one application

I wanted to know if I can run a facebook with multiple application tabs all from the same application. E.g. I have a tab welcome located under /welcome of my app as well as the tab contact located under /contact. In facebook application settings I can set the domain path http://example.com/ and the page tab location as http://example.com/welcome ... but I want to use more than one tab on a page with my application <-- is this possible or should I have to create for each application tab a new application?? :-|
Greetings
Denis
Unfortunately no. Currently you can only have one tab per app per Page. If you want to add multiple tabs to a single Page, you'll need to have a separate app for each one.
It is possible to serve different tab content to different Pages from one app by using the profile_id property of the signed_request parameter. Check out the other properties of the signed_request parameter for more ideas about ways you can customize Page tab content on the fly.