2015-12-14 36 views
-3

我期待實現網站上的解決方案,讓用戶張貼鏈接,一旦發佈像它會在Facebook的鏈接將擴大內容獲取元數據例如,Linkedin如何從一個鏈接

I.e. '標題','簡短描述','圖像'。

我怎麼能做到這一點?

+0

您已經放在一起的任何代碼? – RST

+0

還沒有,我在谷歌周圍搜索,但我不知道是否有一個特定的術語,我錯過了爲什麼我沒有收到我想要的任何結果。謝謝。 –

+0

這件事背後的邏輯是獲取服務器上的鏈接內容獲取並找到標題和圖像,然後用數據更新您的項目。 [file_get_contents](http://php.net/manual/en/function.file-get-contents.php)將爲您提取數據,您需要完成剩下的工作。 –

回答

2

您可以使用PHP的功能get-meta-tags()了點。

例子:

<?php 
// Assuming the above tags are at www.example.com 
$tags = get_meta_tags('http://www.example.com/'); 

// Notice how the keys are all lowercase now, and 
// how . was replaced by _ in the key. 
echo $tags['author'];  // name 
echo $tags['keywords'];  // php documentation 
echo $tags['description']; // a php manual 
echo $tags['geo_position']; // 49.33;-86.59 
?> 

參見: http://php.net/manual/en/function.get-meta-tags.php

相關問題