Search code examples
phpfacebookvideoyoutube-apiembedding

How does facebook, google+ come up with video thumbnail when typed in url of youtube video?


I have a website where i want users to post the link to videos(from youtube and vimeo) and render a thumbnail related to the link typed in above. I want to generate iframe embed when typed a link

I am using php

Any help on how this can be done?


Solution

  • In YouTube Data API v3, you can get video's thumbnails with videos->list function.

    From snippet.thumbnails.(key), you can pick the default, medium or high resolution thumbnail, and get it's width, height and URL.

    You can also update thumbnails with thumbnails->set functionality.

    For examples, you can check out YouTube API Samples project. (PHP ones)