Authenticate sites with different domain names using the Facebook API
We have a CMS that supports multiple sites, one of our functions allows our users (site administrator) to connect to the site's facebook account to allow status updates, create events and upload photos to FB using the CMS.
Authentication must be done once, as each site can have multiple site administrators who do not have access to the site's FB username and password. We use an iframe and authenticate with $ facebook-> require_login (), which redirects the user to the FB login and authentication pages.
This all works great, but when the user clicks "Allow" the authentication will break as it will only redirect to what is in the "Post-Authorize Redirect URL" field, making the application obsolete for any other domain besides " Redirect URL after authorization "
I know that other API authentication methods such as Vimeo and YouTube will allow you to specify a NEXT parameter equivalent to "post-authorization redirect URL" and can be set at runtime.
How can I make this work for multiple domain names?
Any hints on this issue would be very helpful
source to share
If the callback page is on your domain this page can act as a proxy, all you have to do is pass the parameters required on the proxy page to redirect the user to the correct location. For example, I used the url of the domain that I want to redirect and the ID I need to find out which user I am dealing with.
My code ends up looking something like this:
Authorization link:
$authorizeURL = "http://www.facebook.com/authorize.php?api_key=" . $facebookApiKey . "&v=1.0&ext_perm=status_update&domainName=$domainName&path=/path/to/my/next/page.php";
and the "proxy" code should look something like this:
$path = $_GET['path'];
$query = $_GET['query'];
$domainName = $_GET['domainName'];
//if you happen to have a query, get the values like this:
parse_str($query, $queryValues);
$id = $queryValues['id'];
// construct the url where your user came from or where you want them to be redirected.
$url = "http://$domainName/$path?$query";
header("Location: " . $url);
exit;
This is not all the code, but it will give you an idea of how to do it.
source to share