2012-09-03 52 views
3

我想動態地添加一個AddThis工具箱。 Twitter &電子郵件接收來自共享配置文件的一些變量,但Facebook共享從那裏沒有得到任何信息。AddThis: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'}); 

回答

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); 
}); 

Working Example Here.

+0

我可能不清楚.. Facebook按鈕出現。但是當我分享時,它不會從共享配置對象('{title:'aaa'}')分享標題名稱。 – Miki

0

書面上AddThis documentation

一些服務,最值得注意的是Facebook和LinkedIn,不使用 參數我們發送給他們。相反,他們使用元標記來確定要共享的URL,標題和描述。

某些服務(例如Facebook和Linkedin)只是忽略這些配置信息,因爲從Open Graph元標記中獲取數據。所以你應該添加Open Graph元標記到你的HTML中(嘗試閱讀this useful resource),如果你遇到AJAX加載內容的一些問題,也許你可以通過強制url通過特定的addthis方法來解決(顯然是在新內容之後已被加載):

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

現在,通過Facebook共享將從頁面中打開的圖元標記正確獲取其數據。

這是一個很好的資源,以解決我面臨了類似的問題:

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

希望這可以幫助,再見!

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

結果將會是: http://4.bp.blogspot.com/-sV8ulEsNnSE/TdizQQPgNXI/AAAAAAAAAD4/JElqfUuGf60/s400/fb-share.jpg – xr0x