避免应用程序请求对话框中出现错误 100:无效参数(需要有效的重定向 URI)
我正在为 Facebook 开发一款游戏。我需要一种让用户邀请其他人加入游戏的方法。为此,我使用应用请求对话框。我将用户重定向到对话框 URL,将其粘合在一起,如下所示:(
$url = "http://www.facebook.com/dialog/apprequests?app_id=".$id."&message=".urlencode("foobar")."&redirect=".urlencode("http://some.arbitrary.url.com");
当然,使用不那么随意的参数,但它们对我来说仍然看起来很正常。)导航到那里后,用户会被“API 错误代码”责骂:100,API 错误描述:参数无效,错误消息:需要有效的重定向 URI。”。我用谷歌搜索了一个解决方案,但似乎所有收到此错误的人都忘记转义他们的网址/消息。我还尝试了一些无需备注即可接受的 URL,例如应用程序画布 URL。
有谁知道我犯了什么错误?
I'm developing a game for Facebook. I need a way for users to invite others to the game. For that, I use the apprequests dialog. I redirect the user to the dialog URL, which I glue together like this:
$url = "http://www.facebook.com/dialog/apprequests?app_id=".$id."&message=".urlencode("foobar")."&redirect=".urlencode("http://some.arbitrary.url.com");
(Of course, with not-so-arbitrary arguments, but they still look sane to me.) Upon navigating there, the user is scolded by "API Error Code: 100, API Error Description: Invalid Parameter, Error Message: Requires valid redirect URI.". I googled around for a solution, but it seems that all the people receiving this error were forgetting to escape their URLs / messages. I also tried some URLs that should be accepted without remarks, like the application canvas URL.
Does anyone know what mistakes am I making?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因此,解决方案是使用
redirect_uri
和不转义要重定向到的 URL,因此我之前编写的代码应为:So, turns out the solution is to use
redirect_uri
and not to escape the URL to redirect to, so the code I wrote before should read:尝试将
redirect
参数替换为redirect_uri
Try replacing the
redirect
parameters withredirect_uri
根据我对这个错误的经验;无论导致错误的参数是什么,facebook都会给你同样的错误。
我的问题是我没有对所有参数使用
encodeURIComponent(contentParam);
,因此任何参数中的任何特殊字符都会给我带来上述错误。From my experience with this error; facebook gives you same error whatever the parameter which caused the error.
my problem that I didn't use
encodeURIComponent(contentParam);
for all the parameters so any special character in any parameters gave me the above error.