what am trying to do is check if the video entered by the users really exists or not , I have searched a lot and found this : ReRetrieving_Video_Entry , but it looks like it deprecated, so how is it possible using Google APIs Client Library for PHP
to check if video exists or not?
I have fixed it using this technique, which doesn't require any use of API
:
$headers = get_headers('https://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=' . $key);
if(is_array($headers) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$headers[0]) : false){
// video exists
} else {
// video does not exist
echo json_encode(array('Error','There is no video with that Id!'));
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments