Facebook External Widget development with a single app - facebook

We're trying to develop a widget that uses Facebook APIs and other websites (e.g different domains) could embed. We do not want every website to create it's on Facebook app but we'd like everyone using this widget to be connected to our Facebook app.
The problem is that Facebook seems to authenticate only a specific domain for an app (Canvas URL).
Ideas?
Guy
Update: I just realized that for Facebook server API as long as I set the redirect_uri to a valid URL (as defined by the site url) then everything is OK. So I can let my widget call the login and set the redirect_uri to some page we hold on our server that will communicate with the origin. So far so good. Now the problem that remains is whether there's a way to do it using the Facebook JS sdk rather then having to invent the wheel. From what I see there I could find a way to make the JS SDK not use the window.location.href. Ideas?

you just need to create the app, then from the profile site of your app there is an link to let users add the app to their page. (this is also possible via a special link (see the docs))
but be aware, one page can only include your app once. so if you like your "customers" to have your app multiple times on the same page you have to create multiple apps but point the canvas and tab url to the same script.
The other way would be to add child applications directly for the user, so you can let your customers even set a customized icon. This is hard to code couse you have to use old apis (newer one doesnt support the functions anymore) and there is none to null documentation for it. (I have such an app running, if you want to see some examples drop me a note)

Related

Facebook connect service for my customers without appid

I have more than few clients that would like to add facebook connect to their landing pages (managed by me). They are too many and not enough tech-savvy to manually create ad appid for each of them.
So my only solution is to usa my own appid to add facebook connect to all my clients websites, but as far as I know, Facebook doesn't allow to simply use the same appid on any domain.
How can I solve this? I can't find any documentation to solve my issue. Does anyone have a direction for me?
This has been discussed a couple o’ times before already – but I mostly commented on earlier questions, so let me write the whole thing up as a proper answer, for future reference.
[paraphrased] Multiple-client Facebook login via one single app id
Does anyone have a direction for me?
You probably rather don’t want to do that.
It is not really possible to run one simple app one multiple different domains.
As a workaround for only a few domains, people used to specify different domains for the different platforms – Website, Page Tab or Canvas App, plus Mobile alternative for Canvas – without actually using any of those platforms besides Website, which made the app usable on multiple domains as a website app. But since Facebook introduced their login/permission review process¹, you can’t do that any more – they expect you to present actual functionality on all platforms you have configured in your app.
You can kind-off use one single app for login on multiple domains – if you are willing to use only the server-side login flow, and to redirect users to one “main” domain (that gets specified as the app domain in the app settings) to login, and then from there back to the origin domain.
But this has several drawbacks:
It’s not what you’d call a “white label” solution. If your clients expect it to look as if users where logging in via “their” app, it should stay on their domain. Individual branding, in regard to stuff such as app name, app logo that shows in the login dialog, etc., would also not be possible. Additionally, app attribution – the link that shows up under content shared/posted via the app – would only link users back to the main domain, and not to your customer’s.
You would not be able to use the JS SDK for client-side API requests, or even just to embed it to render any of the FB social plugins that require an app id – the SDK checks what domain it is “running on”, and can not be tricked to accept a domain that is not specified in the app settings.
There could be privacy issues. An over-exaggerated example: Just because I as the app user decided to share my photos or videos I have on Facebook with your customer Our-Holy-Mother-of-Christ-Bakery.com, does not necessarily mean I want to share them with your other customer, amateurs-doing-all-kinds-of-nasty-stuff.xxx as well – but if they shared an app id for login purposes, I automatically would. Have fun writin’ the Privacy Policy (which is mandatory if you use FB login functionality, and FB also automatically checks if your app has got one) for that scenario ;-)
Finally, and most importantly: All your customers would be “sitting in the same boat.” If one of them, or in turn their website users, would publish spam via your app id, so that Facebook blocks it, login would not work any more for all of your customer’s websites. And if you decide only then, that setting up an individual app for each of your customers would be the better way to go, they would not be able to recognize their existing users any more, because of user ids being app-scoped since API v2.0 was introduced – so if users logged into this new app, that app would see a totally different user id. (And to rely on an email address as an identifier is risky, too, because you will not get one from the API for every user; for example if they registered using their mobile device.)
Edit: Plus, app/domain insights, as luschn mentioned in his answer.
¹ Yes, the review process has made it more laborious to set up multiple apps for multiple clients. But for apps that do the same stuff/use the same permissions in the same manner, you can refer to an earlier successfully reviewed app id to speed up the process a little. Also, screenshots of how f.e. posts made via the app look on timeline, and what UI components are used, as well as screencasts that you include in your submission could probably be used with little to no alteration.
Apps are not meant be used on several different domains, you will have to create a new App for each domain, i´m afraid. You can use the different platforms in the App settings to use different domains, but there are only a few so it´s pointless. Just create some screenshots and a tutorial for your clients, that´s how it is usually done.
Btw, it would be weird to authorize an App on a website, and the same App would allow you to be authorized on all other client websites. Also, insights are per App, so your clients may want to see their own insights and not the global insights of all domains together.
Many is not defined but i think for being a smart developer you need to create new app_ids for every project you need to use facebook connect. Just my opinion. It also allows you to monitor alot of stuff.

Use same app on multiple domains

I'm creating a Social Media management webapp. This webapp will be used by our customers on there own sites (read, own domains). The webapp connects to a facebook app that we own, to allow them to manage there pages.
I'm using the "Website" platform for the app. During development I've had the "Site URL" set to my localhost url, and the "App Domains" set to localhost. This has worked fine.
However I now realise that this app will not always be run from localhost. It will be run from many differnt domains. I've read many posts about how its not possible to do this anymore, or at least the max is 5 domains by adding multiple platforms.
So how am I supposed to do this? Will I need to create an app on my profile for each customer/site? Will I have to create an app on each customers facebook account and link its app ID to our webapp?
The solution for this was not so bad.
Since AccessTokens are portable, so you can generate them on a single domain, and then use them to access the API from any page.
To do this, I have setup a single page on my own server (not customers server), whos domain is in my Apps Domains property. This page just has the facebook JS SDK, and some code to handle whether or not to show a login or a logout button. I embed this as an iFrame inside my webapp (that can run from any URL). I use
FB.Event.subscribe('auth.authResponseChange' function {});
to look for status changes, then use the the JS postMessage method to send the result of this to the parent of the iFrame, who then sends it to the server. This AccessToken can then be used anywhere.

IFrame application to buy tickets

So I am planning to develop an IFRAME facebook app which lets users buy tickets from Facebook using our website.
Basically I would like to know whether its possible to do what I have in mind.
Each event posted in our website has a specific link associated with it and we already provide a facility whereby event organizers can integrate our app into their website using an IFRAME.
Now I would like to know whether it is possible to have the same concept applied on a Facebook App. Each event will have its own EventId and I do not wish to have all events listed on our App. Each promoter that has his own Facebook page will be able to integrated the APP and will only see his events. Is this possible since you need to bind your Facebook to a specific URL?
Thanks
Yes! This is possible. What you'll need to do is have a tab application that the promoter installs on their page. Each promoter installs the exact same application so you only need to have one.
When the app is loaded within the page, it will receive a signed_request parameter. You'll need to decode it first, but once you do, you'll be able to see where the app is running because the signed_request will contain the page_id. Once you know what page is displaying your application, you'll be able to display appropriate content.

Load Javascript SDK outside Facebook App

I am working on a use case suggesting some Facebook user may invite his friends to use a given Facebook app, regardless of whether this user is using the App or not. This implies invoking dialogs from the Facebook JS SDK outside of the App Canvas.
Simply including the script path in the remote page would have been too easy. So my question is, is it programmatically possible to load the JS SDK from an arbitrary domain ?
So my question is, is it programmatically possible to load the JS SDK from an arbitrary domain ?
Of course it is – countless websites use it, outside of Facebook.
You might have to specify the domain in your app settings, though. Otherwise Facebook will not allow features like f.e. login/connecting to the app from really “arbitrary” domains.

If I create an application on Facebook does it also need a front end on my home website?

If I create an application on Facebook that populates the canvas / iframe on Facebook, do I have to have anything on the home domain that also works? For example, if I have myapp.com do I need an interface on that page that operates independent of facebook for any reason or can I just use my home domain to serve the php files for the iframe in facebook? Also, is there any reason I can't have a separate set of webpages not in facebook that introduce the app, about, contact us, etc.?
Thanks.
Your app will run from your webserver but doesn't have any requirements for showing anything directly from your website. In other words you could create a directory on your webserver and isolate your app.
I'm not aware of any limitations discussing your app in your website but a quick glance over the FB terms of service might highlight anything specific you're trying to do.