AddThis:Facebook分享忽略共享配置

3

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

我错过了什么?

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'});
3个回答

0
你可以尝试一下 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);
});

这里有一个工作示例。


我可能没有表达清楚。 Facebook按钮出现了。但是当我分享时,它没有从共享配置对象({title: 'aaa'})获取要分享的标题名称。 - Miki

0

AddThis文档所述:

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

一些服务(例如Facebook和LinkedIn)会忽略这些配置信息,而是从Open Graph元标签中获取数据。

因此,您应该将Open Graph元标签添加到您的HTML中(可以参考这个有用的资源),如果遇到AJAX加载内容的问题,也许您可以通过强制使用特定的addthis方法来解决(当然是在新内容被加载后):

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

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

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

AddThis按钮不会更新以包括片段(#哈希标签)

希望这可以帮助你,再见!


0
<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>

结果将是: http://4.bp.blogspot.com/-sV8ulEsNnSE/TdizQQPgNXI/AAAAAAAAAD4/JElqfUuGf60/s400/fb-share.jpg - Fun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接