我正在尝试在我的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表单,我还需要做些什么吗?如果有人愿意写一个代码示例,那么代码示例会对我有所帮助。
答案 0 :(得分:2)
以下是我在运营的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方法完全相同,所以类似的东西应该适合你。
我想指出,<?php echo $message; ?>
作为Facebook.streamPublish()
电话的第一个参数。假设$message
是一个文本字符串,那么您需要将该输出包装在引号中,以使其成为有效的Javascript。同样,return attachment;
行对我来说没有多大意义。为什么那里有退货声明?我会将您的代码更改为:
<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
Facebook.streamPublish('<?php echo addslashes($message); ?>', attachment, null, <?php echo $user; ?>);
</script>
答案 1 :(得分:1)
对于FBML画布页面,您只需执行以下命令:
<script type="text/javascript">
var attachment = <?php echo json_encode($attachment); ?>;
Facebook.streamPublish('', attachment, null);
</script>
这应该很容易调出Feed表格。