I have a facebook app that requiers authorization, therefore I have to pass a redirect url along with the authentification-request.
My app is entierly front-end code.
If I wan’t the standalone-version, I can just pass the window.location.href
Something like this won’t work for the app-page, because it’s iframes from different servers. Therefore I have to hardcode the app-url in this case.
The app is intended to be embedded on different app-pages, so I can’t hardcode that. Apperntly I can get the facebook page-tab-link etc using the facebook api. Haven’t looked in to the details yet though. Redirect back to page tab after user authenticates?
As facebook doesn’t allow parameters, my plan is to add /pagetab/ or /app/ to the end of my url, and add that to the various urls in the settings of facebook. After that I will create different cases for the different url-endings.
Although this soultion sounds like a lot of work. Is there a better way to do this?
If your app wasn’t totally client-side, then you could find the info which page your app is embedded on in the
signed_requestparameter. But since Facebook POSTs that to the iframe on calling your app, there is no way of accessing it client-side.Facebook allows for a parameter called
app_datain the URL, which is passed on to your app. But again, this happens via POST on first page load.If you were willing (and able to, regarding your platform) to make the little adjustment of having your apps HTML code generated by a server-side language (instead of it being purely static HTML pages), then you could easily evaluate the
signed_requestparameter, and have the page id written into a JavaScript variable, so that you can use it client-side from there.