URLs Not Allowed: Facebook PHP Login

I keep getting the following error:

This URL is not allowed by application configuration. One or application settings settings are not allowed. This should match the website URL or canvas URL, or the domain should be a subdomain of one of the application domains.

when I try to login using 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 read similar questions here , here , here , here and here , and they all seem to say the same thing: my site URL (the site with Facebook login) is incorrect.

But my Openshift url is like this

 http://myappname-mynamespace.rhcloud.com 

so that I put the URL of the Facebook site in the field. I have the following PHP code ( index.php ) in the root of my Openshift mechanism:

 <?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 the URL of your Facebook ( http://apps.facebook.com/myappname ), Hello World! , and my login link is displayed on top of my Facebook iframe application. However, when I click on the login link, I get the above error. Any help would be greatly appreciated!

EDIT

I entered the following URLs in my browser and Hello World , and both links were shown.

 http://myappname-mydomainname.rhcloud.com/ https://myappname-mydomainname.rhcloud.com/ 
+6
source share
1 answer

While I was still messing around with the Facebook API, I kept getting the same error. It turns out that some URLs with http were supposed to be https, and not that facebook made a point, leaving the correct instructions. I suggest changing the Site URL: http://myappname-mynamespace.rhcloud.com to Site URL: https://myappname-mynamespace.rhcloud.com . If this does not help, I would suggest looking at the other URLs and changing them. Good luck

+2
source

Source: https://habr.com/ru/post/954906/


All Articles