我正在使用JS-API生成一个对话,要求允许发布我的应用程序生成的状态消息。下面是我所说的截图。
这里是代码。
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
我使用了文档中的示例JS代码,如果在浏览器设置中不阻止弹出窗口,它可以很好地工作。
请大家帮忙,我卡在了最后一个阶段。
我不明白为什么它困扰着你。如果用户屏蔽了FACEBOOK的弹出窗口,那么这是他的损失!
总之,如果你真的需要处理所有的情况,那么你可以选择不同的方式。请看一下 饲料对话.
你可以做的是,当你从上一步完成后,你将你的页面重定向到Facebook的feed方法,所以它会打开一个页面。
http://www.facebook.com/dialog/feed?
app_id=123050457758183&
link=http://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!&
redirect_uri=http://www.example.com/response
重要的部分要改变这里是 app_id
和 redirect_uri
所以你的代码会是这样的
...
previous code
...
inside previous code success response
...
var url = "http://www.facebook.com/dialog/feed?" +
"app_id=" + YOUR_APP_ID + "&" +
"link=http://developers.facebook.com/docs/reference/dialogs/&" +
"picture=http://fbrell.com/f8.jpg&" +
"name=Facebook%20Dialogs&" +
"caption=Reference%20Documentation&" +
"description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&" +
"message=Facebook%20Dialogs%20are%20so%20easy!&" +
"redirect_uri=" + YOUR_REDIRECT_URI;
top.location.href = url;
你的代码很好 它为我带来了Feed Dialog。你的问题出在其他地方。你是否添加了 <div id="fb-root"></div>
? 确保它在页面顶部,就在后面的 <body>
标签。
同时确保你正确加载FB Javascript SDK。
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
使用这个代码,你忘了添加显示属性
FB.ui(
{
method: 'feed',
display: 'popup',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);