FBML 墙贴,点击图像或按钮
我正在使用 FBML 创建一个 Facebook 应用程序。我想要的是: 我有几张图像,例如,
<fb:tag name="img">
<fb:tag-attribute name="src">http://My_Img_Url_1.jpg</fb:tag-attribute>
</fb:tag>
<fb:tag name="img">
<fb:tag-attribute name="src">http://My_Img_Url_2.jpg</fb:tag-attribute>
</fb:tag>
当我单击图像时,它应该打开一个弹出窗口“发布到墙上”或“发布到您朋友的墙上”以及相应的图像 My_Img_Url_n.jpg。
我可以使用 FBML 共享按钮,例如:
METHOD-1
<fb:share-button class="meta">
<meta name="title" content="Image_TITLE"/>
<meta name="description" content="Image_Descrip"/>
<link rel="image_src" href="http://My_Img_Url_1.jpg"/>
<link rel="target_url" href="Some_Target_URL"/>
</fb:share-button>
或
METHOD-2: 我可以调用 fb:ui
<script>
FB.init({
appId:'111111111111111', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
name: '',
link: '',
picture: 'http://My_Img_Url_1.jpg'
});
</script>
现在的问题是:
- 如果我单击任何图像,它将调用 METHOD-1 或 METHOD-2,并且会弹出该图像。我怎样才能做到这一点?
- 如果我使用
发布到朋友的留言墙上,我该怎么办?
I'm creating one facebook application with FBML. What I want is:
I have several images like,
<fb:tag name="img">
<fb:tag-attribute name="src">http://My_Img_Url_1.jpg</fb:tag-attribute>
</fb:tag>
<fb:tag name="img">
<fb:tag-attribute name="src">http://My_Img_Url_2.jpg</fb:tag-attribute>
</fb:tag>
While I click on the image it should open one popup "post to wall" or "Post to your Friend's wall" with the corresponding image My_Img_Url_n.jpg.
I can use FBML share button like:
METHOD-1
<fb:share-button class="meta">
<meta name="title" content="Image_TITLE"/>
<meta name="description" content="Image_Descrip"/>
<link rel="image_src" href="http://My_Img_Url_1.jpg"/>
<link rel="target_url" href="Some_Target_URL"/>
</fb:share-button>
OR,
METHOD-2:
I can call fb:ui
<script>
FB.init({
appId:'111111111111111', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
name: '',
link: '',
picture: 'http://My_Img_Url_1.jpg'
});
</script>
Now the questions are:
- If I click on any image it will call either METHOD-1 or METHOD-2 and it will popup with that image. How can I do that?
- If I use
<fb:multi-friend-input />
for posting to friend's wall, How can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会选择选项 2,因为 FBML 很快就会被弃用 (https://developers.facebook.com/docs/reference/fbml/)。
总而言之,初始化 JS SDK,确保您的用户已登录,然后使用新函数包装 FB.ui 调用。然后将图像以 HTML 格式写入页面,并分配单击事件来调用新的 Javascript 函数。
该示例将发布到用户墙上。如果您想发布到另一个用户墙,您首先需要使用 FB.api('me/friends', myGreatCallback) 获取当前用户的好友 ID(请参阅 https://developers.facebook.com/docs/reference/javascript/FB.api/),然后将其传递到 postToWall ()
我写了这个,但没有尝试运行它,如果您遇到任何错误,请告诉我;)。您可以在以下位置找到有关 Facebook JS SDK 的更多信息: https://developers.facebook.com/文档/参考/javascript/
I would go with option 2 as FBML is going to be deprecated soon (https://developers.facebook.com/docs/reference/fbml/).
To sum up, initialize the JS SDK, make sure that your user is logged in and then wrap the FB.ui call with a new function. Then write out your images to the page in HTML and assign the click event to call your new Javascript function.
This example will post to the users wall. If you want to post to another users wall, you'll first need to grab the current users friends IDs with FB.api('me/friends', myGreatCallback) (see https://developers.facebook.com/docs/reference/javascript/FB.api/) and then pass this into postToWall()
I wrote this without trying to run it, let me know if you run into any any errors ;). You can find more information on the Facebook JS SDK at: https://developers.facebook.com/docs/reference/javascript/