2011-09-27 72 views
3

我有一個頁面,其中包含用戶可以選擇的項目表。我想添加一個Facebook Like按鈕。Facebook Like Button with prepopulated Comment

當用戶點擊類似按鈕時,它會彈出評論框,我想根據用戶點擊的項目來幫助預填充評論。如果他們願意,他們可以改變它,或者他們可以保持原樣。如果選擇了這些表格行,它會說「我喜歡Item-1和Item-4」。

甚至可以預先填充評論字段嗎?

如果是這樣,每當用戶更改其選擇時,是否可以通過javascript更改它?

回答

1

無法預先填充Like按鈕的註釋字段,因爲它必須是用戶生成的。但是,您可以爲每個表格行創建唯一的網址,以便在類似的按鈕故事中生成唯一的內容來表示用戶喜歡的內容。例如:

<fb:like href="http://www.example.com/example.php?row=row1"></fb:like> 
<fb:like href="http://www.example.com/example.php?row=row2"></fb:like> 

與每個唯一網址關聯的OG元數據應代表該行的商品信息。例如:

<meta property="og:title" content="Row 2 Item"/> 
<meta property="og:type" content="website"/> 
<meta property="og:url" content="http://www.example.com/example.php?row=row2"/> 
<meta property="og:image" content="http://www.example.com/example_row2.jpg"/> 
<meta property="og:site_name" content="example"/> 
<meta property="og:description" content="Information about item at row 2"/> 
+0

該死,這太糟糕了。感謝您的澄清和模擬功能的想法。乾杯!! – James