2012-12-10 24 views
0

我想在facebook自定義動作文章中添加一個自定義鏈接到[對象](以紅色標記,下方)。如何爲Facebook創建不同的URL自定義動作

enter image description here

這是我的代碼:

FB.api('/me/testapponens:cook', 'post', 
{ recipe: 'http://foobar.com/page1.html' }, 
    function(response) { 
    if (!response || response.error) { 
     alert('Error occured'); 
    } else { 
     alert('Cook was successful! Action ID: ' + response.id); 
    } 
}); 

現在,因爲我已經在我的「配方」,當這貼,開放式圖形屬性採摘表示「http://foobar.com/page1.html」從此頁面。

問題:我需要顯示的鏈接的第三方鏈接www.thirdparty.com/page1.html但是開放圖形元屬性不能在thirdparty.com/page1.html寫入(因爲我不對該頁面有任何控制)。

所以,我決定這樣做:

i) Create a dummy page : www.foobar.com/page1.html. 
ii) Add all the og meta to it. 
iii) Add a redirect (javascript) code to the dummy page so that it goes to the third party page. 

www.foobar.com/page1.html看起來是這樣的:

<html ...> 
<title> Page 1 </title> 
<meta property="fb:app_id"   content="..." /> 
... 
<script type="text/javascript"> 
function redirect1() 
{ 
    window.location = "http://thirdparty.com/page1.html" 
} 
</script> 
</head> 
<body onLoad="redirect1()"></body> 
</html> 

問題:我認爲這是一個哈克方法,它可能不接受用戶。有沒有更好的方法來做到這一點?如果我無法解釋我打算做什麼,請告訴我。

PS:我不是垃圾郵件發送者,第三方頁面來自客戶端,我不想誤導用戶。

回答

1

我認爲這是一種拙劣的方法,它可能不被用戶接受。有沒有更好的方法來做到這一點?

你可以做一個服務器端重定向,檢查用戶代理 - 只有當它是且是Facebook的刮板,重定向客戶端,否則讓刮板讀取網頁的OG元信息。

如何檢測FB刮刀:https://developers.facebook.com/docs/reference/plugins/like/#scraperinfo

+0

感謝您的支持。任何不涉及重定向的建議? –

+0

不可能 - 如果您不能直接將OG標籤放入目標網址,那麼您必須重定向。 – CBroe

+0

好吧。謝謝。 –

相關問題