0

我有产品列表页面。我想显示每个产品的共享链接,并且我想共享单个产品图像。我怎样才能做到这一点 ?

我相信元没有帮助,因为我需要分享个人产品形象。

4

1 回答 1

1

为每个图像创建自己的按钮,从 JS SDK https://developers.facebook.com/docs/reference/javascript/FB.ui/ onclick 调用 FB.UI, 传入消息所需的变量

因此,对于每个图像,html 可能类似于:

<img src="path-to-image" title="title" data-uri="path-to-full-product" />

然后使用像 jquery 这样的库,您可以拥有以下脚本

 $('img').click(function(){
      var $this = $(this);
      var obj = {
      method: 'feed',
      link: $this.data('uri'),
      picture: $this.attr('src'),
      name: $this.attr('title'),
      caption: 'Your caption here',
      description: 'Your description here.'
    };
    function callback(response) {
     alert( "Post ID: " + response['post_id']);
    }

    FB.ui(obj,callback);
 });

带有示例的更多信息在这里:

https://developers.facebook.com/docs/reference/dialogs/feed/

你可以在这里使用 JS-SDK

https://developers.facebook.com/tools/console/

于 2012-05-15T14:19:51.090 回答