Javascript facebook apprequests 对话框错误“发生错误。请稍后再试。”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6365531/
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-23 21:26:00  来源:igfitidea点击:

facebook apprequests dialog error "An error occurred. Please try again later."

javascriptfacebookdialogrequest

提问by Nikhil

I am trying to build-in 'invite a friend' in my app. I am using FB.ui. It seems to work (I am using standard code from http://developers.facebook.com/blog/post/464/.

我正在尝试在我的应用程序中内置“邀请朋友”。我正在使用 FB.ui。它似乎工作(我使用来自http://developers.facebook.com/blog/post/464/ 的标准代码。

But the iframe where you should be able to send a request to your friends just says: "An error occurred. Please try again later."

但是您应该能够向您的朋友发送请求的 iframe 只是说:“发生错误。请稍后再试。”

I didn't forget to use access token.

我没有忘记使用访问令牌。

echo '<div id="fb-root"></div>';
echo '<script src="http://connect.facebook.net/en_US/all.js">';
echo '  </script>';
echo '  <script>';
echo "    FB.init({appId:'215089721847404', cookie:true, status:true, xfbml:true});";

echo "    FB.ui({ method: 'apprequests', message: 'Here is a new Requests dialog...', display: 'iframe', access_token: '$token'});";
echo '  </script>';

Did fb stop allowing request dialogs from within apps? Or am I doing something wrong? Does someone have another solution? Please help.

fb 是否停止允许来自应用程序内的请求对话框?还是我做错了什么?有人有其他解决方案吗?请帮忙。

Update: Maybe that is because I didn't put redirect_uri. Now I did and it doesn't give the error, but now the iframe just doesn't stop loading... Does anyone have an idea?

更新:也许那是因为我没有放置redirect_uri。现在我做了,它没有给出错误,但现在 iframe 只是没有停止加载......有没有人有想法?

采纳答案by Rufinus

Request 2.0 are tricky, all parts have to be exactly as facebook wants it, or it will not work.

Request 2.0 很棘手,所有部分都必须完全符合 facebook 的要求,否则将无法运行。

see http://af-design.com/blog/2011/02/17/using-facebook-requests-to-promote-a-website/for a good example on how to do it.

请参阅http://af-design.com/blog/2011/02/17/using-facebook-requests-to-promote-a-website/以获取有关如何执行此操作的一个很好的示例。

回答by John Hawkins

I was having the same problem with several different calls the the apprequests method of the Facebook API, but intermittently.

我在 Facebook API 的 apprequests 方法的几个不同调用中遇到了同样的问题,但时断时续。

In the end I found that the problem was being caused by calling the FB.ui function in inline javascript like you do. It would work fine sometimes, but on a slow network I always got the same error.

最后我发现问题是由像您一样在内联 javascript 中调用 FB.ui 函数引起的。有时它会正常工作,但在慢速网络上我总是遇到同样的错误。

I fixed it by simply putting the FB.ui call within a function and using setTimeout call to trigger it after the page has completely loaded, like this

我通过简单地将 FB.ui 调用放在一个函数中并在页面完全加载后使用 setTimeout 调用来触发它来修复它,就像这样

    function callAppReq() {
        FB.ui({ method: 'apprequests', 
                title: 'My Title', 
                message: 'Here is a new Requests dialog...'},
             function(response) {
             }
        );
    }
    var t=setTimeout("callAppReq()",3000);

回答by mjs

One more possible catch is that facebook will not let you send app requests till you have configured your app domain.. Without mentioning app domain FB shall give you "An error occurred. Please try again later facebook apprequest error" consistently

另一个可能的问题是,在配置应用域之前,facebook 不会让您发送应用请求。如果不提及应用域,FB 将始终为您提供“发生错误。请稍后再试 facebook apprequest 错误”

Settings >> Basic Info >> App Domains

设置 >> 基本信息 >> 应用域