【问题标题】:AddThis: Facebook share ignores sharing configurationAddThis:Facebook 分享忽略分享配置
【发布时间】:2012-08-28 12:12:37
【问题描述】:

我正在尝试动态添加 AddThis 工具箱。 Twitter 和电子邮件从共享配置文件中接收到一些变量,但 Facebook 共享没有从那里获得任何信息。

我错过了什么?

HTML:

<span class="toolbox1 addthis_toolbox">
  <a class="addthis_button_facebook"></a>
  <a class="addthis_button_twitter"></a>
  <a class="addthis_button_linkedin"></a>
  <a class="addthis_button_email"></a>
</span>

JS:

toolbox_obj = $('.toolbox1').get(0);
addthis.toolbox(toolbox_obj,sharing_config,{title: 'aaa'});

【问题讨论】:

    标签: javascript jquery facebook facebook-opengraph addthis


    【解决方案1】:

    你可以试试这个

    HTML

    <span class="toolbox1 addthis_toolbox"></span>​
    

    JS

    var tbx = $(".toolbox1").get(0),
    svcs = {facebook: 'Facebook', twitter: 'Twitter', linkedin:'Linkedin', email: 'Email'};
    $.each(svcs, function(k, v){
        $('<a></a>', { class:'addthis_button_'+k }).appendTo(tbx);
    });
    

    Working Example Here..

    【讨论】:

    • 我可能不太清楚.. facebook 按钮出现了。但是当我分享时,它并没有从分享配置对象({title: 'aaa'})中获得分享的标题名称。
    【解决方案2】:

    写在AddThis documentation:

    一些服务,尤其是 Facebook 和 LinkedIn,不使用 我们发送给他们的参数。相反,他们使用元标记来确定 要分享的 URL、标题和描述。

    一些服务(例如 Facebook 和 Linkedin)只是忽略这些配置信息,因为从 Open Graph 元标记中获取数据。

    所以你应该在你的 HTML 中添加 Open Graph 元标记(尝试阅读this useful resource),如果你遇到 AJAX 加载内容的问题,也许你可以通过特定的 addthis 方法强制 URL 来解决(显然在新的内容已加载):

    addthis.update('share', 'url', window.location.href); // re-parse the url
    addthis.ready(); // re-render the buttons.
    

    现在通过 Facebook 分享将正确地从页面中打开的 Graph 元标记中获取其数据。

    这是解决我遇到的类似问题的好资源:

    AddThis buttons wont update to include fragment (#Hash Tag)

    希望对你有帮助,再见!

    【讨论】:

      【解决方案3】:
      <HEAD>
      <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
      <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
      
      <meta property="og:title" content="Your Title" />
      <meta property="og:type" content="website" />
      <meta property="og:image" content="Your Thumbnail Image Link" />
      <meta property="og:url" content="Your URL" />
      <meta name="description" content="Your Description" />
      
      <HEAD>
      
      
      <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
      
      猜你喜欢
      • 2013-03-15
      • 1970-01-01
      • 2010-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多