使用启用严格模式的Facebook PHP SDK登录时出错 [英] Error on Login using Facebook PHP SDK with Strict Mode Enabled

查看:111
本文介绍了使用启用严格模式的Facebook PHP SDK登录时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Facebook收到通知,称它们将使来自 2018年3月的有效OAuth重定向URI中未列出的URI的呼叫无效,我认为它们要求我们启用严格模式(用于重定向URI).可以在此处找到链接.

I got a notification from Facebook saying that they will invalidate calls from URIs not listed in the Valid OAuth redirect URIs this coming March 2018 and I think they are requiring us to Enable Strict Mode for Redirect URIs. Link about this can be found here.

我已经在禁用严格模式的情况下使用他们的PHP SDK一年了,没有任何问题,但是当我启用严格模式并将重定向网址放置在其中时:

I have been using their PHP SDK with Strict Mode disabled for a year now without any problem however when I do enable strict mode and place there the redirect url which is: https://nino-dot-dynamic-osprey-93721.appspot.com/admin/fb-callback_admin.php - it returns an error as seen below each time I try to Login with Facebook:

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.

请注意,我只是在使用FB的默认PHP SDK登录代码( https://developers.facebook.com/docs/php/howto/example_facebook_login ),其中具有login.php和fb-callback.php链接,但我没有使用任何自定义OAuth工作流程.

Note that I'm simply using FB's default PHP SDK Login code (https://developers.facebook.com/docs/php/howto/example_facebook_login) which have login.php and fb-callback.php links and I'm not using any custom OAuth workflows.

我注意到生成的重定向URL包含 code state 参数:

I noticed that the redirect URL generated contains the code and state parameters:

site.com/admin/fb-callback_admin.php?code=somecode&state=somestate

我认为这是我收到错误消息的原因,因为它只希望重定向URL为

I think this is the reason why I'm getting the error because it only expects a redirect URL of https://nino-dot-dynamic-osprey-93721.appspot.com/admin/fb-callback_admin.php without any trailing parameters.

考虑到重定向URL通过以下代码的响应,你们如何考虑解决启用严格模式"这一问题:

How do you guys think of getting around this issue of Enabling Strict Mode given that the response of the redirect URL through the below code:

$helper = $fb->getRedirectLoginHelper();
$permissions = ['email']; // Optional permissions
$loginUrl = $helper->getLoginUrl('https://nino-dot-dynamic-osprey-93721.appspot.com/admin/fb-callback_admin.php', $permissions);
echo htmlspecialchars($loginUrl);

默认情况下是从FB的PHP SDK生成的吗?

is generated from FB's PHP SDK by default?

推荐答案

更改

$accessToken = $helper->getAccessToken()   

$accessToken = $helper->getAccessToken('http://www.example.com/admin/fb-callback_admin.php');

我遇到了同样的问题,并在此线程中找到了这个答案,这似乎为我解决了这个问题:

I had the same issue and found this answer in this thread, which seems to resolve the problem for me:

图形返回错误:无法加载URL:此URL的域未包含在应用程序的域中

虽然不确定为什么能奏效,但很高兴能做到.

Not sure why this works, though, but glad it did.

这篇关于使用启用严格模式的Facebook PHP SDK登录时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆