-3

I've googled and looked at the docs, but haven't found anything related.

From of them image,I would like to know how facebook do that when I type or paste url then detail of website will show in box and it can use in timeline.

Now I write in javascript language and php, I want to know how it work for my website

Thank you very much

2 Answers2

3

Most of webmasters now are adding meta tags to their pages called OpenGraph which holds the image,title,desc etc. So when you type the URL facebook simply make a request to that URL and retrive the HTML and parse it to obtain the OG tags values and then displays it.

If there are not Open Graph tags it will make the same request but now it will parse the HTML in another way to obtain title,image,desc .. etc

For example it will read the title tag For the title and maybe the meta description for the description and the image their algorithm might select the biggest image or the first image it depends on them.

If there is no meta tags and title most likely it will parse the actual HTML content to obtain some info from it, for example it will take the <h1> as the title and so on.

It's really not standard process it depends on their algorithms BUT for the OpenGraph meta tags it's straight forward

I hope this can help :)

Seder
  • 2,735
  • 2
  • 22
  • 43
1

Use below given lines in <head> tag:

<meta property="og:title" content="TYPE YOUR TITLE TO BE DISPLAYED IN FACEBOOK"/>
    <meta property="og:url" content="TYPE URL"/>
    <meta property="og:site_name" content="WEBSITE NAME"/>
    <meta property="og:image" content="THE IMAGE THAT IS DISPLAYED IN FACEBOOK BOX"/>
    <meta property="og:description" content="DESCRIPTION IN FACEBOOK" />
Lavneet
  • 516
  • 5
  • 19