php 重定向到身份验证对话框 - “发生错误。请稍后再试”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7231939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:17:53  来源:igfitidea点击:

Redirecting to authentication dialog - "An error occurred. Please try again later"

phpfacebookfacebook-graph-api

提问by Wanderson Silva

Why does it always happen to me?

为什么总是发生在我身上?

This happens after my application verify for user user login and redirect user to the authentication page:

这发生在我的应用程序验证用户用户登录并将用户重定向到身份验证页面之后:

https://www.facebook.com/dialog/oauth?client_id=XXX&redirect_uri=http%3A%2F%2Fexample.com%2Fmyappname%2F&state=YYYYYY&scope=offline_access%2Cpublish_actions

https://www.facebook.com/dialog/oauth?client_id=XXX&redirect_uri=http%3A%2F%2Fexample.com%2Fmyappname%2F&state=YYYYYY&scope=offline_access%2Cpublish_actions

But instead of showing the authorization page, Facebook shows an error page with

但是 Facebook 没有显示授权页面,而是显示了一个错误页面

An error occurred. Please try again later.

发生错误。请稍后再试。

Is there any configuration I have to do before try to authenticate my users?

在尝试对我的用户进行身份验证之前,我是否需要进行任何配置?

All is done with PHP using the PHP-SDK classes.

所有这些都是使用 PHP-SDK 类通过 PHP 完成的。

采纳答案by albert

I had the same problem after changing the domain of my site. Altough I properly changed the request_uri parameter and updated my app settings with the new domain, the error kept showing up. Then I realized that the ID and the SECRET ID of my Facebook APP had automatically changed with no warning!! The whole thing started working again using the new ID.

更改网站域后,我遇到了同样的问题。尽管我正确更改了 request_uri 参数并使用新域更新了我的应用程序设置,但错误仍然出现。然后我发现我的 Facebook APP 的 ID 和 SECRET ID 在没有任何警告的情况下自动更改了!!整个过程使用新 ID 重新开始工作。

回答by dxit

I have had the same problem as you.

我和你有同样的问题。

From the Facebook Developers Apps page, make sure that the Sandbox Mode is disabled.

在 Facebook Developers Apps 页面,确保禁用沙盒模式。

enter image description here

enter image description here

回答by Juank

This was happening to me also but all the api keys, secrets and stuff were correct. What I found is that my app was running in sandbox mode. Go to your app settings in https://developers.facebook.com/click the advanced settings tab and check to see if your app is in sandbox mode. If it is disable it and try again. Let us know if it works.

这也发生在我身上,但所有的 api 密钥、秘密和东西都是正确的。我发现我的应用程序在沙盒模式下运行。转到https://developers.facebook.com/ 中的应用设置,单击高级设置选项卡并检查您的应用是否处于沙盒模式。如果是禁用它,然后再试一次。让我们知道它是否有效。

回答by case2000

I was getting this error because I was starting from http://mysite.com, but had specified http://WWW.mysite.comin my Facebook settings - the www mattered... I ended up solving by using .httpaccess to always kill the "www", and pointing FB to http://mysite.com

我收到此错误是因为我从 开始http://mysite.com,但已http://WWW.mysite.com在我的 Facebook 设置中指定- www 很重要...我最终通过使用 .httpaccess 始终杀死“www”并指向 FB 来解决http://mysite.com

worst. subdomain. ever. :u)

最糟糕。子域。曾经。:u)

回答by Pete

When working with Dialogues, Facebook provide a 'show_error' attribute that defaults to nobut can be set to truein a Development environment and is really helpful for debugging purposes.

使用 Dialogues 时,Facebook 提供了一个“show_error”属性,该属性默认为no但可以true在开发环境中设置为,并且对于调试目的非常有帮助。

show_error - If this is set to true, the error code and error description will be displayed in the event of an error.

show_error - 如果设置为 true,则在发生错误时将显示错误代码和错误描述。

Instructions of it's use can be found in the Facebook Docs.

它的使用说明可以在Facebook 文档中找到。

I'd been debugging "An Error occurred. Please try later." dialogue before i found this attribute in the docs. Once i started using it, i could see the following message too:

我一直在调试“发生错误。请稍后再试。” 在我在文档中找到这个属性之前的对话。一旦我开始使用它,我也可以看到以下消息:

API Error Code: 191

API Error Description: The specified URL is not owned by the application

Error Message: redirect_uri is not owned by the application.

API 错误代码:191

API 错误描述:指定的 URL 不属于应用程序

错误消息:redirect_uri 不属于应用程序。

回答by James Pelton

For me this happened because the "test user" I created was part of a separate app. I created a test user for THIS app, and it started working fine.

对我来说这是因为我创建的“测试用户”是一个单独的应用程序的一部分。我为这个应用程序创建了一个测试用户,它开始工作正常。

Stupid on my part I know, but this could save someone else some trouble.

我知道我很愚蠢,但这可以为其他人省去一些麻烦。

回答by JaredBroad

I had the same problem; it turned out FB requires a stringappID and not an int...

我有同样的问题; 结果 FB 需要一个字符串appID 而不是一个int...

//DOESNT WORK:
$facebook = new Facebook(array(
  'appId'  => 147XXXXXXXXXXX,
  'secret' => 'XXXXXXXXXXXXXX',
));

// WORKS:
$facebook = new Facebook(array(
  'appId'  => '147XXXXXXXXXXX',
  'secret' => 'XXXXXXXXXXXXXX',
));

回答by SBerg413

Make sure your app is configured to use the appropriate URL & domain of your site. That may be it.

确保您的应用配置为使用您网站的适当 URL 和域。可能就是这样。

回答by Tomas Molnar

According to OAUTH Dialog documentation:

根据 OAUTH 对话文档:

*redirect_uri:The URL to redirect to after the user clicks a button in the dialog. The URL you specify must be a URL of with the same Base Domain as specified in your app's settings, a Canvas URL of the form https://apps.facebook.com/YOUR_APP_NAMESPACE...*

* redirect_uri:用户单击对话框中的按钮后重定向到的 URL。您指定的 URL 必须是与您的应用设置中指定的基本域相同的 URL,格式为https://apps.facebook.com/YOUR_APP_NAMESPACE...*的 Canvas URL

I am constructing oauth links dynamically to ask a user for additional permissions if needed and I realized, that even if you are redirecting to https://apps.facebook.com/YOUR_APP_NAMESPACEyou have to have the App Domain and Website settings set in your application administration. I set domain to facebook.com and Website to facebooks root url.

我正在动态构建 oauth 链接以在需要时向用户询问其他权限,我意识到,即使您重定向到https://apps.facebook.com/YOUR_APP_NAMESPACE,您也必须在您的应用程序域和网站设置中设置应用管理。我将域设置为 facebook.com,将网站设置为 facebook 的根 url。

Now my oauth dialog link works fine - even in sandbox mode.

现在我的 oauth 对话框链接工作正常 - 即使在沙箱模式下。

回答by Owen Davey

I had this exact problem on a Page Tab app and for the life of me couldn't work out what the problem was. It worked on my test page but as soon as I made it live it wouldn't work. I found in the end that I fixed the problem by putting the actual URL to the Page Tab (i.e. http://www.facebook.com/<"page_name">/app_<"app_id">) into "Site URL" under "Website". This doesn't make any sense. But it worked :-)

我在 Page Tab 应用程序上遇到了这个确切的问题,我一生都无法弄清楚问题是什么。它在我的测试页面上工作,但一旦我上线,它就无法工作。最后我发现我通过将页面选项卡的实际 URL(即http://www.facebook.com/<"page_name">/app_<"app_id">)放入“网站”下的“站点 URL”中来解决问题。这没有任何意义。但它奏效了:-)