Tero

Check YouTube video if exist without using api

Dec 13th, 2020 (edited)
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. function vidCheck($vid) {
  2.   $url = 'https://img.youtube.com/vi/'.$vid.'/0.jpg?fresh='.time();
  3.   $headers = get_headers($url);
  4.   return (substr($headers[0], 9, 3) == 200) ? true : false;
  5. }
  6.  
  7. // usage; video id from url: https://www.youtube.com/watch?v=z3PpphdrEmU
  8. // echo vidCheck('z3PpphdrEmU');
Advertisement
Add Comment
Please, Sign In to add comment