2015-12-14 39 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

相关问题