1

I'm not the greatest programmer so sorry if this is a obvious issue but I really hope someone can help me. I am stumped.

I am trying to make my site run solely over https including a basic php Facebook integration, that captures data from the users profile.

The below code works as expected:

require_once __DIR__ . '/vendor/autoload.php';
$fb = new Facebook\Facebook(['app_id' => '','app_secret' => '','default_graph_version' => 'v2.7',]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email,user_location']; // Optional permissions
$loginUrl = $helper->getLoginUrl('http://'.$_SERVER['SERVER_NAME'].'/profile.php', $permissions);
echo '<a href="' . htmlspecialchars($loginUrl) . '">Facebook!</a>';

However, changing the line:

$loginUrl = $helper->getLoginUrl('https://'.$_SERVER['SERVER_NAME'].'/profile.php', $permissions);

Returns the error:

"Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings."

I have all the same settings for HTTPS and HTTP in Facebook app settings and the Facebook log in settings. I can't work it out...

james
  • 11
  • 3
  • Are you sure you switched your app to https on [Facebook](https://developers.facebook.com/apps/) ? – Faegy Jan 25 '17 at 20:52
  • Thanks for responding! In my App settings have updated my site URL to be https:// and in the Facebook Login Settings I have updated the Valid OAuth redirect URIs to be the same as the HTTP. Is there another setting that I am overlooking? – james Jan 25 '17 at 21:24
  • Well from what I know you should change two separated links in the Facebook settings. One is about your "Domain" (top of settings page) and the other one is the "Web page" a little bit lower. Be sure to edit your "web page" url before your domain as your domain must be a previously added "web page" url. – Faegy Jan 25 '17 at 22:29
  • The domain settings don't allow for changing the protocol, just the domain that the app is being accessed by and I know that is ok as it works over http://. Thanks for taking the time to help. – james Jan 25 '17 at 22:45
  • 1
    Sounds like you're having similar issues to this person: http://stackoverflow.com/questions/37063685/facebook-oauth-the-domain-of-this-url-isnt-included-in-the-apps-domain – Tama Jan 26 '17 at 07:52
  • Yes, similar but I'm not changing my domain. The only change is introducing https:// – james Jan 26 '17 at 11:08
  • So I have figured out the issue. For some reason (I honestly don't know why) but my hosting provider sends SSL traffic over port 80 and they are unable to route it over 443. Changing the port to 443 would solve the issue (if anyone else has this issue). Unfortunately, my provider is unable to change this port. I have tried forcing the the URL to use :443 but unfortunately, this flags other issues with validating where the URL came from as it redirects traffic back to :80. Hope the above helps someone else in the future. – james Jan 29 '17 at 15:33

0 Answers0