我有一个iframe Facebook应用程序(使用Facebook的新JavaScript应用程序接口),需要允许用户邀请他们的朋友参加比赛后的应用程序。我在页面的div中有以下标记(编辑了应用程序名称和画布Url ):
<fb:serverFbml>
<fb:request-form
method="POST"
invite="true"
type="{Name of My Application}"
content='Your text goes here. %3Cfb%3Areq-choice%20url%3D%{a url-encoded link to my Canvas URL}"/>'
label="Authorize My Application">
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use My Application.">
</fb:multi-friend-selector>
</fb:request-form>
</fb:serverFbml>据我所知,如果你需要在XFBML/iframe应用程序中使用FBML标签,你只需将它们放入fb:serverFbml元素中,Facebook就会处理它。果然,我的第一印象似乎是错误的。我没有在表单中插入,而是得到了一个白色的空盒子,其中的fbml看起来没有任何变化。
这个应用程序的设计假设(可能是错误的),我不需要对用户进行身份验证就可以邀请他们的朋友。有没有办法做到这一点,或者我需要要求他们先登录?Facebook的文档(当然)在这一点上含糊不清。
根据请求编辑: My FB.init():
$("body").prepend("<div id=\"fb-root\"></div>");
FB.init({
apiKey: "{My apiKey is here}",
appId: "{My appId is here}",
status: true,
cookie: true,
xfbml: true
});发布于 2010-09-14 02:37:17
好了,我把它弄好了。下面是我对它的看法:
<fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form action='my_url' method='POST'
invite='true'
type='Poll'
content='This is an invitation! <fb:req-choice url="my_url" label="Accept and join" /> '>
<fb:multi-friend-selector showborder='false' actiontext='Select friends to send the poll' cols='5' rows='3' bypass='cancel' max="8">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>JS注入代码如下所示:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'YOUR APP ID HERE',
status: true,
cookie: true,
xfbml: true
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>所以,
1)你不需要你的应用密钥,只需要JS代码中的应用ID。
2)需要将XFBML包装在脚本标记中。
发布于 2011-05-13 22:35:08
此示例也适用:
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=APP_ID&xfbml=1"></script><fb:serverfbml>
<script type="text/fbml">
<fb:fbml>
<fb:request-form action='my_url' method='POST'
invite='true'
type='Poll'
content='This is an invitation! <fb:req-choice url="my_url" label="Accept and join" /> '>
<fb:multi-friend-selector showborder='false' actiontext='Select friends to send the poll' cols='5' rows='3' bypass='cancel' max="8">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverfbml>在http://connect.facebook.net/en_US/all.js#appId=[APP_ID]&xfbml=1中设置APP_ID
https://stackoverflow.com/questions/3592514
复制相似问题