根据 facebook 即将弃用所有 FBML 应用程序,我建议您查看这里,并尝试以这种方式创建一个对话框。我可以给你我目前正在使用的脚本,你圈出的链接指向我的应用程序的主页。应该记下 - 我的应用程序是 Iframe 应用程序。
<script type="text/javascript">
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'name',
caption: 'caption',
source: 'picture.jpg',
picture: 'picture.jpg',
description: 'description',
href: 'http://apps.facebook.com/appname'
},
action_links: [
{ text: 'name', href: 'http://apps.facebook.com/appname' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
但是,如果您希望将应用程序保留为 FBML 表单,请尝试以下代码:
<script type="text/javascript">
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'name',
caption: 'caption',
source: 'picture.jpg',
picture: 'picture.jpg',
description: 'description',
href: 'http://apps.facebook.com/appname/index.php'
},
action_links: [
{ text: 'name', href: 'http://apps.facebook.com/appname/index.php' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
您需要了解 Iframe 和 FBML 应用程序之间的区别:虽然 Iframe 应用程序使用户始终停留在同一个页面上,并且只有 Iframe 中的内容发生变化,但 FBML 应用程序实际上将用户从一个页面移动到另一个页面。因此,在 FBML 应用程序中指定链接时,使用http://apps.facebook.com/appname/page
链接而不是http://www.yoursite.com/page
链接很重要。
示例链接:
- 您网站上的链接:
http://www.yoursite.com/game1.php
- 在 FBML 应用程序中看起来像这样:
http://apps.facebook.com/appname/game1.php