在同一页面上使用 Like 按钮和 FB.ui (apprequests) 存在冲突
我遇到了画布应用程序的问题。如果启用“赞”按钮的代码,FB.ui 调用“apprequests”会出错。如果我注释掉“赞”按钮,它就会恢复正常。使用“stream.publish”的调用可以正常工作。
我的初始化代码:
FB.init({
appId : '12345',
status : true,
cookie : true,
xfbml : true,
channelUrl : '/channel.html',
oauth : true
});
使用 FB 工具生成的 Like 按钮的代码:
<div style="padding-left:177px">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=12345";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/apps/application.php?id=12345" data-send="false" data-width="450" data-show-faces="false" data-colorscheme="dark"></div>
</div>
FB.ui 调用:
FB.ui(
{
method: "apprequests",
display: "iframe",
message: "You have to check this out!"
},
function(response) {
if (response && response.request_ids) {
$.post("response.php", { rid: response.request_ids, data: data }, function(result) {
});
}
}
);
调用 FB.ui 时用户遇到的错误:
API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key
感谢任何帮助!
I've ran into a problem with a canvas app. If the code for the Like button is enabled, the FB.ui call 'apprequests' gives an error. If I comment out the Like button, its back to normal. Calls with 'stream.publish' work normally tho.
My Init code:
FB.init({
appId : '12345',
status : true,
cookie : true,
xfbml : true,
channelUrl : '/channel.html',
oauth : true
});
The code for the Like button, generated with the FB tool:
<div style="padding-left:177px">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=12345";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/apps/application.php?id=12345" data-send="false" data-width="450" data-show-faces="false" data-colorscheme="dark"></div>
</div>
The FB.ui call:
FB.ui(
{
method: "apprequests",
display: "iframe",
message: "You have to check this out!"
},
function(response) {
if (response && response.request_ids) {
$.post("response.php", { rid: response.request_ids, data: data }, function(result) {
});
}
}
);
The Error users get when the FB.ui is called:
API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key
Any help is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用“iframe”显示方法时,您必须传递有效的 access_token:https://developers .facebook.com/docs/reference/dialogs/
You have to pass a valid access_token when using the 'iframe' display method per: https://developers.facebook.com/docs/reference/dialogs/
只需删除显示:“iframe”,对我有用。它仍然会显示在 iframe 中,但不会出现错误。不要问我为什么,使用 1:1 相同的应用程序设置,它可以与我的另一个应用程序中的显示值配合使用...
just remove display: "iframe", worked for me. it will still show in an iframe, but without error. don´t ask my why, with 1:1 the same app settings it works WITH the display value in another app of mine...