Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 649
Edward Avatar asked Oct 03 '13 22:10

Edward


People also ask

How can I change my Facebook callback URL?

In the "Facebook Login" tab under your app, enter all valid callback URL's, such as http://localhost/callback, http://productionUrl/callback, etc. If you don't see "Facebook Login" tab under your app, click "Add Product-> Facebook Login->Get Started" Enter the Valid Callback Urls -> Save changes.

How do I add another page on the Facebook app?

Go to your App and select "App Details" Under "Contact Info" you will find "App Page". There you will be able to create a new page or if all went well, select your page from a list.


2 Answers

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.

like image 62
Lix Avatar answered Sep 18 '22 21:09

Lix


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

like image 20
Edward Avatar answered Sep 22 '22 21:09

Edward