Facebook 多好友选择器不渲染(iFrame 应用程序)
我有一个 iframe Facebook 应用程序(使用 Facebook 的新 JavaScript API),需要允许用户在参加比赛后邀请他们的朋友加入该应用程序。我在页面上的 div 中有以下标记(应用程序名称和 Canvas 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 的文档(当然)对此含糊其辞。
编辑:我的 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
});
I have an iframe Facebook application (using Facebook's new JavaScript API) that needs to allow the user to invite their friends to the app after entering a contest. I have the following markup in a div on the page (application name and Canvas Url redacted):
<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>
From what I understand, if you need to use FBML tags in an XFBML/iframe app, you just drop them into an fb:serverFbml element and Facebook takes care of it. Sure enough, my first impressions seem to be false. Instead of dropping in the form, I just get an empty white box, with the fbml seemingly untouched.
The design of this application assumes (probably incorrectly) that I don't need to authenticate the user to let them invite their friends. Is there a way to accomplish this, or do I need to require them to log in first? Facebook's documentation is (of course) vague on this.
EDIT: My FB.init() as requested:
$("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
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我已经开始工作了。对我来说,它是这样的:
JS 注入代码如下所示:
所以,
1)你不需要 APP KEY,只需要 JS 代码中的 APP ID。
2) XFBML 需要包装在 SCRIPT 标签内。
Ok, I got it to work. Here is how it looks for me :
and the JS injection code looks like this :
So,
1) You dont need your APP KEY, only your APP ID in the JS code.
2) The XFBML needs to be wrapped inside a SCRIPT tag.
此示例也有效:
在 http://connect.facebook.net/en_US/all.js#appId=[APP_ID]&xfbml=1 中设置 APP_ID
This example works too:
Set APP_ID in http://connect.facebook.net/en_US/all.js#appId=[APP_ID]&xfbml=1