问题描述
我遇到了一个画布应用程序问题.如果启用了赞"按钮的代码,则FB.ui调用"apprequests"将给出错误.如果我将赞"按钮注释掉,它会恢复正常.
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.
我的初始化代码:
FB.init({
appId : '12345',
status : true,
cookie : true,
xfbml : true,
channelUrl : '/channel.html',
oauth : true
});
使用FB工具生成的喜欢"按钮的代码:
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>
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时出现错误用户:
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
感谢您的帮助!
推荐答案
使用"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/
这篇关于在同一页面上使用“赞"按钮和FB.ui(请求)冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!