Tero icon

Check YouTube video if exist without using api

Tero | PRO | 12/13/20 10:28:46 AM UTC (Edited) | 0 ⭐ | 1012 👁️ | Never ⏰ | []
PHP |

290 B

|

None

|

0 👍

/

0 👎

function vidCheck($vid) { 
  $url = 'https://img.youtube.com/vi/'.$vid.'/0.jpg?fresh='.time();
  $headers = get_headers($url);
  return (substr($headers[0], 9, 3) == 200) ? true : false;
}
 
// usage; video id from url: https://www.youtube.com/watch?v=z3PpphdrEmU
// echo vidCheck('z3PpphdrEmU');

Comments