2012-05-22 20 views
0

我正在做一個項目,我必須嚮應用程序用戶顯示項目描述,我擁有的是產品的url,url可以來自任何網站它可能是來自亞馬遜,易趣等產品的網址搜索了很多後,我發現Facebook的鏈接器做我想要的項目,從單個網址生成元標記,生成元標記後,我會得到我需要這些標籤的信息,但問題是如何生成這些標籤。如何生成meta標籤就像facebook的linter那樣

下面是我的product.php我曾經在Facebook上棉短絨

<html> 
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# article: http://ogp.me/ns/article#"> 
<meta property="fb:app_id" content="xxxxxxxxxxxxxx" /> 
<meta property="og:url" content="http://rads.stackoverflow.com/amzn/click/0596006810" /> 
<meta property="og:site_name" content="social" /> 
<meta property="fb:profile_id" content=""> 
<meta property="og:type" content="website" /> 
<meta property="og:image" content="" /> 
<meta property="og:title" content="" />  
</head> 
<body> 
</body> 
</html> 

調試。當我按下Debug按鈕的代碼,它產生的meta標籤如下圖所示 enter image description here

我想顯示與facebook linter生成的相同的輸出,以向我的用戶顯示產品圖像和描述。

在此先感謝

回答

1

如果我理解你的問題吧...

你的網站的meta標籤:

<meta name="custom_image_tag" content="http://yoursite.com/images/product_1.jpg" /> 
<meta name="custom_description_tag" content="The product description" /> 

PHP代碼來獲取標籤

$tags = get_meta_tags('http://www.yoursite.com/some-page.html'); 

echo $tags['custom_image_tag']; 
echo $tags['custom_description_tag']; 

至於亞馬遜,你可以使用他們的標題元標記和從頁面中刪除圖像。

+0

奧斯汀,標籤陣列中沒有圖像索引,產品和關鍵字返回相同的數據,我只想要產品圖像和產品說明 – tariq

+1

我向您展示了這個概念。沒有標準的圖片或產品標籤,這些標籤定製到每個網站。 – AustinAllover