如何使用 Facebook FBJS Feed 表单

发布于 2024-08-16 11:37:03 字数 576 浏览 2 评论 0原文

我正在尝试在 Facebook 应用程序中调用 Feed 表单,但不知道该怎么做。我不熟悉 FBJS 及其 API。具体来说,我需要显示以下对话:http://wiki.developers.facebook。 com/index.php/Feed_Forms

这是我现在得到的:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
return attachment;
Facebook.streamPublish(<?php echo $message; ?>, attachment, null, <?php echo $user; ?>);
</script>

为了正确调用 Feed 表单,我还需要做些什么吗?如果有人愿意写一个代码示例,那么它会对我有很大帮助。

I'm trying to call a Feed Form in my Facebook application and I'm not sure how to do so. I'm not familiar with the FBJS and its API. Specifically I need the following dialogue to show up: http://wiki.developers.facebook.com/index.php/Feed_Forms

Here's what I got for now:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
return attachment;
Facebook.streamPublish(<?php echo $message; ?>, attachment, null, <?php echo $user; ?>);
</script>

Is there anything else I need to do in order to properly call a Feed form? A code example would help me a lot if anyone is willing to write one up.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一场春暖 2024-08-23 11:37:03

下面是我在我运营的 Facebook Connect 网站上使用的示例:

var message = 'This is my message!';
var attachment = {
    'name':'Page name',
    'href':'http://mysite.com',
    'caption':'Some kind of caption';
};
attachment.media = [{'type':'image','src':'http://mysite.com/images/lolcat.jpg','href':'http://mysite.com'}];
var action_links = [{'text':'Action Link!','href':'http://mysite.com'}];
FB.Connect.streamPublish(message, attachment, action_links);

FB.Connect 方法几乎与普通 JS 方法相同,因此类似的方法应该适合您。

我想指出你有 作为 Facebook.streamPublish() 调用的第一个参数。假设 $message 是一个文本字符串,那么您需要将该输出用引号引起来,以使其成为有效的 Javascript。同样,returnattachment;行对我来说没有多大意义。为什么那里有一个 return 语句?我会将你的代码更改为:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
Facebook.streamPublish('<?php echo addslashes($message); ?>', attachment, null, <?php echo $user; ?>);
</script>

Here's an example I use from a Facebook Connect site that I operate:

var message = 'This is my message!';
var attachment = {
    'name':'Page name',
    'href':'http://mysite.com',
    'caption':'Some kind of caption';
};
attachment.media = [{'type':'image','src':'http://mysite.com/images/lolcat.jpg','href':'http://mysite.com'}];
var action_links = [{'text':'Action Link!','href':'http://mysite.com'}];
FB.Connect.streamPublish(message, attachment, action_links);

The FB.Connect methods are almost identical to the normal JS methods, so something similar should be working for you.

I would point out that you have <?php echo $message; ?> as the first parameter to your Facebook.streamPublish() call. Assuming $message is a text string, then you need to wrap that output in quotes in order for it to be valid Javascript. As well, the return attachment; line doesn't make much sense to me. Why is there a return statement there? I would change your code to this:

<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
Facebook.streamPublish('<?php echo addslashes($message); ?>', attachment, null, <?php echo $user; ?>);
</script>
旧人哭 2024-08-23 11:37:03

对于 FBML 画布页面,您所需要做的就是执行如下命令:

<script type="text/javascript">

var attachment = <?php echo json_encode($attachment); ?>;

Facebook.streamPublish('', attachment, null);       

</script>

这应该可以轻松调出 Feed 表单。

For FBML canvas pages, all you need to do is execute the command as follows:

<script type="text/javascript">

var attachment = <?php echo json_encode($attachment); ?>;

Facebook.streamPublish('', attachment, null);       

</script>

That should easily bring up the Feed Form.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文