I keep getting the following error
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
when I try to login a user with my PHP code snippet (see below). My Facebook settings are as follows:
App Domains: myappname-mynamespace.rhcloud.com www.myappname-mynamespace.rhcloud.com
Site URL: http://myappname-mynamespace.rhcloud.com/
Canvas Page: http://apps.facebook.com/myappname
Canvas URL: http://myappname-mynamespace.rhcloud.com/
Secure Canvas URL: https://myappname-mynamespace.rhcloud.com/
I've read similar questions here, here, here, here and here and they all seem to say the same thing: my Site URL (Website with Facebook Login) is incorrect.
But my Openshift URL is like this
http://myappname-mynamespace.rhcloud.com
so that's what I put in Facebook Site URL field. I have the following PHP code (index.php) in the root of my Openshift gear:
<?php
require 'php-sdk/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxx',
'secret' => 'xxxx'
));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Facebook PHP</title>
</head>
<body>
<h1>Hello World!</h1>
<?php
// get user from facebook object
$user = $facebook->getUser();
if ($user): // check for existing user id
echo '<p>User ID: ', $user, '</p>';
else: // user doesn't exist
$loginUrl = $facebook->getLoginUrl(array(
'display' => 'popup',
'redirect_uri' => 'http://apps.facebook.com/myappname'
));
echo '<p><a href="', $loginUrl, '" target="_top">login</a></p>';
endif;
?>
</body>
</html>
What am I doing wrong?
When I enter my Facebook app's URL (http://apps.facebook.com/myappname), Hello World! and my login link is display on top of my Facebook's app's iframe. However when I click on the login link, I get the above mentioned error. Any assistance will be greatly appreciated!
EDIT
I entered the following urls in my browser and Hello World and the login link were both displayed.
http://myappname-mydomainname.rhcloud.com/
https://myappname-mydomainname.rhcloud.com/