Facebook PHP SDK - Login helper returns error

拈花ヽ惹草 提交于 2019-12-18 09:44:30

问题


i have created a app witch are using facebook as a login opportunity. My APP worked public fine 1 day ago, but today it started getting this error when my users are logging in:

Graph returned an 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.

My code looks like this:

<?php
require 'vendor/autoload.php';

if(!session_id()) {
    session_start();
}

// Setting a local setting
$fb = new Facebook\Facebook([
  'app_id' => '****',
  'app_secret' => '****',
  'default_graph_version' => 'v2.2',
  ]);

// Setting up the Facebook Helper
$helper = $fb->getRedirectLoginHelper();

//Genneration FaceBook Callback Script
$loginUrl = $helper->getLoginUrl('https://gymbilletter.dk/facebook/facebook_callback.php',array('scope' => 'email'));
header("Location: ".$loginUrl);

And i have whitelisted my return domain: Facebook OAuth Rederictlinks

I have tried to search the interned for answers, but the only answers i get is to update from 5.6.1 to 5.6.2 but i am already using 5.6.3


回答1:


Hi i faced same issue over here

https://stackoverflow.com/a/52096688/1234825

and tried a different approach

Facebook seems to have "short of" break its own code. By enabling enfore https, the Validate OAuth url no longer validates.

I have added the following param on my redirect url to bypass the issue

https://mysubdomain.mysite.gr/index.php?r=site/callbackfb&enforce_https=1



回答2:


I'm currently working on Graph api version v2.2

If you open Enforce HTTPS on in Facebook Login settings.

Go to you facebook-php-sdk and inside that

Facebook\Helpers\FacebookRedirectLoginHelper.php

change $redirectUrl:

$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state','code']);

To

$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state','code','enforce_https']);


来源:https://stackoverflow.com/questions/52086528/facebook-php-sdk-login-helper-returns-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!