How to get Facebook video thumbnail from its video id?

https://graph.facebook.com/VIDEO_ID will give you a lot more info, including bigger thumbnails to pick from. (You can get a list of the available info at https://developers.facebook.com/docs/graph-api/reference/video.)

Here's some PHP code to dig up the biggest thumbnail:

$data = file_get_contents("https://graph.facebook.com/$video_id?fields=format");
if ($data !== FALSE)
{
 $result=json_decode($data);
 $count=count($result->format)-1;
 $thumbnail=$result->format[$count]->picture;
}

Update: The code above has been updated since Facebook changed their API on July 10, 2017. Here is some additional PHP code to get a big thumbnail for a video in case Facebook changes things again:

$data = file_get_contents("https://graph.facebook.com/$video_id/thumbnails?access_token=$facebook_access_token");
if ($data !== FALSE)
{
 $result=json_decode($data);
 $thumbnail=$result->data[0]->uri;
}

This second solution requires a Facebook access token. Here are some instructions on how to get a Facebook access token: https://smashballoon.com/custom-facebook-feed/access-token/

Update: Facebook is making it more and more difficult to even get access tokens with the necessary permissions for such a simple task. Here is how to get the info from the raw HTML:

$data = `curl -s -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0' -L 'https://www.facebook.com/1706818892661729/'`;

if (preg_match('#<video [^>]+></video>\s*<div [^>]+><img [^>]+src="([^"]+)#s',$data,$matches))
 {
  $image = $matches[1]; $image = str_replace('&amp;','&',$image);
  if (strpos($image,'&')) {print "Answer: $image\n";}
 }

Note that if you download the page, Facebook also provides the meta property twitter:image but that image is only 200x200. If Facebook wasn't such a pain in the butt, they would also provide the meta property og:image with a decent size image but they don't.


You can get the thumbnail picture from the video id by going to this Graph API URL - https://graph.facebook.com/VIDEO_ID/picture, e.g. https://graph.facebook.com/115316011865684/picture