2014-02-07 144 views
0

我正在使用以下JS代碼在Facebook上分享。Facebook自定義分享按鈕不顯示說明

function openFbPopUp() { 
    var fburl = 'http://54.251.121.6/cnc/cupcakes-n-chai-side-table'; 
    var fbimgurl = 'http://imageURL'; 
    var fbtitle = 'Your title'; 
    var fbsummary = "This is the description blah blah blah"; 
    var sharerURL = "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" + encodeURI(fburl) + "&p[images][0]=" + encodeURI(fbimgurl) + "&p[title]=" + encodeURI(fbtitle) + "&p[summary]=" + encodeURI(fbsummary); 
    window.open(
     sharerURL, 
     'facebook-share-dialog', 
     'width=626,height=436'); 
    return false; 
} 

在彈出窗口中,說明文字看起來很好。但是當在臉書上看到時,說明並未顯示

分享時,說明(摘要文本)可以看到。 Description Can be seen

但是描述(概要)不顯示在臉書上。

Description not showing up

回答

0

在無論你分享網頁,嘗試將以下內容:

<meta property="fb:app_id" content="{Your_App_ID}"/> 
<meta property="og:url" content="http://54.251.121.6/cnc/cupcakes-n-chai-side-table"/> 
<meta property="og:title" content="Your title"/> 
<meta property="og:image" content="http://imageURL"/> 
<meta property="og:description" content="This is the description blah blah blah"> 

不過,如果你已經在使用JS,如何使用Facebook JS SDK?

只要把下面的代碼的標籤之後:

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '{your-app-id}', 
     status  : true, 
     xfbml  : true 
    }); 
    }; 

    (function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 
</script> 

然後調用共享對話框,只需調用以下:

FB.ui({ 
     method: 'feed', 
     name: 'Your title', 
     link: 'http://54.251.121.6/cnc/cupcakes-n-chai-side-table', 
     picture: 'http://imageURL', 
     caption: '', 
     description: 'This is the description blah blah blah', 
     ref: '{your_reference_call_here}' 
}); 

我個人的經驗表明,使用JS SDK來分享內容比使用URL重定向方法更安全(確保沒有錯誤)。

+0

謝謝@Aashish Tripathee。我無法使用元描述標記,因爲有些頁面需要在頁面的不同塊上使用3-4個不同的元描述標記。 –

+0

然後嘗試使用JS SDK。當涉及到像你的情況一樣分享多個內容時,這絕對有效並且非常好。 – tripatheea