0

In some websites like facebook, when we post some link it show us thumbnails from that website, Like this in Picture below:

enter image description here

How to do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

0

It's just a post/comment like any other. Only thing you need is info about that page. You can use curl for example to fetch page's data. Info you are looking for are in head of document in meta tags.

    <meta name="og:type" content="website" />
    <meta name="og:image" content="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=fde65a5a78c6"/>
    <meta name="og:title" content="Post a link and show thumbails from that link - php" />
    <meta name="og:description" content="In some websites like facebook, when we post some link it show us thumbnails from that website, Like this in Picture below: How to do that?" />

Take those info and make your post/comment/whatever.

EDIT: You don`t even need curl, you can use file_get_contents check out this answer

Community
  • 1
  • 1
Dexa
  • 1,641
  • 10
  • 25
0

you need to fetch that URL and read the meta tags which will give you some information such as title, description etc. If you need to fetch the image weather read the image meta tag (exists if any) or read the first available image from the web page.

Arfeen
  • 2,553
  • 5
  • 29
  • 48