2011-11-03 88 views
7

我正在解決頁面標題和圖像未包含在Facebook喜歡的問題。已經打了OG調試器,它看起來像沒有og:元標記正在被Facebook訪問的:Facebook Open Graph API - og:被忽略的元標記

Here's a link to the debugger - 它說這是推斷og:urlog:title性能,這是出現在頁面上。

作爲測試的問題,我直接從開發人員文檔的示例中複製了元標記和HTML模式,並且仍然收到相同的警告。

這裏所產生的頭部標籤的HTML和啓動:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head> 
<title>123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle</title> 
<meta name="description" content="Transactiv Products" /> 
<meta name="title" content="Transactiv" /> 
<meta property="fb:app_id" content="289501899130" /> 
<meta property="og:site_name" content="Transactiv InRecv" /> 
<meta property="og:url" content="http://localhost:2609/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&PageName=MHMTest&PageID=236549899706529" /> 
<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" /> 
<meta property="og:type" content="website" /> 
<meta property="og:description" content="" /> 
<meta property="og:image" content="http://transactivazureprod.blob.core.windows.net/pictureblob/831a4d4a-dbe3-44f5-9ff8-12286cdc33f5" /> 

在這個任何想法?

回答

5

明顯的缺陷。你不會很快結束標題。你得到了"

我建議在echo'ing之前先做一個str_replace('"', "''", $str)

也就是說,

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10'' x 5'5'' Rectangle" />

編輯:

你也可以考慮做htmlentities($str, ENT_QUOTES),通過@TwoWholeWorms的建議,

+0

你是完全正確的有 - 東西要進行修改 - 但是,即使我沒有這個問題,Facebook的仍然忽略了元標記 - 我也從開放圖形文檔例如拉到值直,他們給我同樣的警告: – SDG

+0

而你正在嘗試與Linter? –

+0

是的 - linter告訴我,即使他們在頁面上推斷那些「必需」的屬性 – SDG

1

Facebook的刮板在嘗試visit your site時看到錯誤頁面。

您可以通過鏈接'查看我們的刮板在調試頁面底部看到的內容'鏈接訪問Facebook刮板的頁面視圖。

而且它不只是似乎當我訪問鏈接是因爲我也看到了同樣的消息刮刀相關的問題:http://transactivstaging.cloudapp.net:8080/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&FBUserId=100002152993326&PageName=MHMTest&PageID=236549899706529&CurrentPage=0

ShoppingCart.GetShoppingCartItems.Failed If this Error persists, you can contact our support and provide the following Error Id as a reference 
0

我猜想,還有"Robin Castlin(您也可以使用&quot;轉義)中提及的標題值中,您的og:url包含非轉義的&符號。

如果您在og:url字段中將&替換爲&amp;,它會起作用嗎?

所以,你會更換

<meta property="og:title" 
    content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" /> 
<meta property="og:url" 
    content="http://localhost:2609/Pages/ProductSummary.aspx? 
    OrganizationProductID= ... &StoreID= ..." /> 

<meta property="og:title" 
    content="123-ABC Butterfly Fun Carpet 3'10&quot; x 5'5&quot; Rectangle" /> 

<meta property="og:url" 
    content="http://localhost:2609/Pages/ProductSummary.aspx? 
    OrganizationProductID= ... &amp;StoreID= ..." /> 

,以確保所有包含有效的HTML元數據。

6

Facebook的讀取所有屬性,你可以輸入你的網址在這裏: https://developers.facebook.com/tools/debug

Facebook將讀取你指定的,但有時會用他們只有當所有4 specfied(而不是空)的屬性,不僅最後3

<meta property="og:url" content="YOUR_URL" /> 
<meta property="og:title" content="YOUR_TITLE" /> 
<meta property="og:description" content="YOUR_DESCRIPTION" /> 
<meta property="og:image" content="YOUR_IMAGE" />