How to Get id from Facebook Video URL by PHP?

Hi friends, today I will tell you through experts tool tutorial how you will get facebook video id through php. So let’s try to understand step to step.

So friends, first of all I would like to tell you that php has a lot of inbuilt function.With this function, the most difficult task can be done very easily. Now let’s talk about how to php id will get it. Friends are in a function called php preg_match. With this we can get the id of video. How will we use this function to get the id of video. These codes are given below.

get-id-from-fb.php

<?php
$facebookurl = "https://www.facebook.com/rahulk/videos/1180300868811118/";
preg_match("#(\d+)/$#", $facebookurl, $video);
echo $video[1];
//1180300868811118 output //
?>

How to Use this Code?

Now you will be told how you can use this code. First of all you create a file named get-id-from-fb.php. Then copy the above code and paste it into the file you created. Run this code on your server and you will get the output.