2011-05-12 49 views
2

我想在我的django應用程序中使用「分享Facebook」功能,而不是新的「FB Like」。 但我無法找到我如何實現它,並設置描述,標題和圖像分享。使用傳統Facebook「分享」按鈕不是Facebook「贊」

任何人都可以幫助我嗎?

UPDATE

我做DeLonge怎麼說。下面的代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <title>Bra</title> 
    <link rel="image_src" href="http://site.com/images/logo.jpg" /> 
    <meta name="description" content="description here"> 
</head> 

<body> 
    <a name="fb_share" type="button" share_url="http://www.sharedomain.com/path/" href="http://www.facebook.com/sharer.php?u=http:/www.sharedomain.com/path&amp;src=sp" style="text-decoration: none; ">Share</a><script src="http://static.ak.fbcdn.net/con 
nect.php/js/FB.Share" type="text/javascript"></script> 
</body> 

</html> 

但是當我按一下按鈕我看到這個錯誤的結果:

enter image description here

想法?

+0

它看起來像代碼,一切都是正確的。您唯一遺漏的是您需要用自己的鏈接和圖像替換「sharedomain.com」和圖像的URL。一旦正確引用的圖像和頁面鏈接,縮略圖/描述就會出現。 – crockpotveggies 2011-05-12 19:53:49

+0

@DeLonge它可以工作,如果我硬編碼的URL。但我需要分享動態網址,例如site.com/profile/ (配置文件/ {{user.username}})我該如何解決? – 2011-05-12 20:58:16

回答

3

我同意「分享」按鈕在某些情況下更有用。見代碼:

<a name="fb_share" type="button_count" share_url="http://www.sharedomain.com/path/" href="http://www.facebook.com/sharer.php?u={INSERT ENCODED share_url HERE}&amp;src=sp" style="text-decoration: none; ">Share</a> 
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> 

類型包括:1)button_count 2)按鈕3)鏈接。

標題將來自頁面本身。然而,添加一個圖標圖像只需添加以下到您的HTML <head>

<link rel="image_src" href="http://www.sharedomain.com/path/thumbnail.jpg" /> 

我知道你是在Django開發,我建議你硬編碼FB分享按鈕。這是因爲Facebook不再推動它,大多數API都在消失。

+0

請參閱我的更新。 – 2011-05-12 19:38:42

+0

是Facebook的緩存問題。現在可以了。謝謝老兄。 – 2011-05-12 22:26:34

+0

很高興我能幫到你。 – crockpotveggies 2011-05-13 06:48:17