2012-07-10 77 views
-1

我想通過apis在facebook牆上發佈消息。問題是,當我通過api發佈,然後當我直接粘貼一個鏈接作爲Facebook的狀態時,它顯示不同。我不確定我是否做錯了什麼。請指教。使用api在Facebook上發佈所需消息

我想張貼作爲例子的鏈接是http://commondatastorage.googleapis.com/blood/2415012_26-May-2012

我使用的代碼是一樣的東西:

FacebookType publishMessageResponse =        facebookClient.publish("me/feed", FacebookType.class, 
Parameter.with("name", "Click here to Register as a Blood Donor"), 
Parameter.with("picture", "http://commondatastorage.googleapis.com/blood/2415012_26-May-2012"), 
Parameter.with("link", "http://links.sakshum.org/RegisterBloodDonor"), 
Parameter.with("description", "Sakshum is a not for profit organization working in the field of child education and building an effective blood donor pool.")); 

回答

1

因爲當你直接粘貼的Facebook試圖推斷元OG標籤。

見調試器的更多信息http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fcommondatastorage.googleapis.com%2Fblood%2F2415012_26-May-2012

推斷的特性:「OG:url」屬性應該是明確 提供,即使一個值可以從其他標籤來推斷。

推測屬性:應該明確提供'og:title'屬性,如果可以從其他標籤推斷出值,則應該明確提供 。

推測屬性:應該明確提供'og:description'屬性,即使可以從其他標籤推斷出 的值。 ...等

設置您的元標記在URL的<head>部分,你不必設置它。

而在你<head>

<meta property="og:url" content="http://commondatastorage.googleapis.com/blood/2415012_26-May-2012"> 
<meta property="og:title" content="Click here to Register as a Blood Donor"> 
<meta property="og:description" content="Sakshum is a not for profit organization working in the field of child education and building an effective blood donor pool."> 
<meta property="og:image" content="http://YOURURL.COM/LINKTOIMG.jpg"> 

欲瞭解更多信息,請參見feedhttp://developers.facebook.com/docs/reference/api/user/#posts

+0

所以在這種情況下,我應該怎麼設置爲元標記出現在鏈接的內容是什麼? – Vik 2012-07-10 05:18:20

+0

@Vik見上文。 – phwd 2012-07-10 05:25:42

+0

謝謝,但你是什麼意思bu的頭部分的網址? – Vik 2012-07-10 05:28:24