How to capture link header + images when sharing

I was wondering how to play Facebook software in PHP:

When you share a link, it captures the page title and automatically captures images from the page to decorate the link.

Is there anything already done, like a plugin that I can take a look at?

Thank.

+3
source share
1 answer

use the PHP DOM classes to pull out the contents of the url and parse the html to get the first <img>url text and <h1>.

UPDATE

use the DOM loadHTMLFile method to load the file into the DOMDocument object.

http://www.php.net/manual/en/domdocument.loadhtmlfile.php

DOM getELementsByTagName, node.

http://www.php.net/manual/en/domdocument.getelementsbytagname.php

nodeValue node

+1

Source: https://habr.com/ru/post/1783923/


All Articles