0
votes

I wanted to add facebook login option on my website, but always getting,

An error occurred with Abhishekmiet. Please try again later.

API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.

I'd set the following in my app setting: Site-url: http[://]ip_address Canvas url: http[://]ip_address/ (the square brackets removed after http) ip_address is my ip address in x.x.x.x pattern, have not posted my actual ip for security purposes.And i'm using the following php snippet for generating base url,

if($_SERVER['HTTP_HOST']=='localhost'){
$base_url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}else{
$base_url='http://'.$_SERVER['HTTP_HOST'];  
}

I've tested it on both my local server and on my live server but always the same error.

1

1 Answers

1
votes

Your base url is not complete. Try this...

$protocol = "http";

if(isset($_SERVER['HTTPS']))
{
    if($_SERVER['HTTPS'])
    {
        $protocol = "https";
    }
}
//Check if the protocol is HTTP or HTTPS

$domainName = $_SERVER['HTTP_HOST'];

$appNamespace = "fercheckin";
//Your namespace specified in your app settings

$appFolder = "it3196/tbfer/fercheckin/";
//Your Canvas/Page Tab URL (Example:http://localhost/it3196/tbfer/fercheckin/)

$fbconfig['appBaseUrl'] =   $protocol."://apps.facebook.com/".$appNamespace;
//For App on Facebook application

$fbconfig['baseUrl']    =   $protocol."://" . $domainName . "/" . $appFolder;
//For Page Tab application

This will work for App on Facebook and Page Tab application, on both local server and live server.