Search code examples
phphtmlfacebookhyperlinkarticle

How to display a linked article's image, title, and description in my LAMP web app


I'm developing a social media platform using a LAMP build. So far my users can upload pictures and videos and comment and vote on them. I want users to be able to post a url link to an article, and have the title, image and description automatically pop up like it does on Facebook. I'm guessing that most web pages containing articles include some sort of meta data that would allow a developer like me to systematically access the title, description fields etc. If this is the case, then how specifically do I access this metadata. Otherwise, how does Facebook do it?

Thanks,


Solution

  • You can use a PHP HTML parsing library that allows you to input a URL, and break out meta information at your choosing.

    This answer on StackOverflow has an excellent list of available HTML parsing options for PHP: https://stackoverflow.com/a/3577662/1332068