Currently, I have a function that builds a vimeo player based on a vimeo ID
function create_video_player_by_ID($video_id){
$player = '<iframe src="http://player.vimeo.com/video/';
$player .= $video_id.'" ';
$player .= 'width="'.$this->width.'" ';
$player .= 'height="'.$this->height.'" ';
$player .= 'frameborder="0"></iframe>';
return $player;
}
Currently, I get a vimeo appology in the player window is the ID is invalid, but I would like to do more with that. How can I get a boolean to return before the video player, so I can do something else an failure?
You can use the HEAD request method using the video URL.
function check_remote_video_exists($video_url) {
$headers = @get_headers($video_url);
return (strpos($headers[0], '200') > 0) ? true : false;
}
Check your vimeo URL like so:
if (check_remote_video_exists('YOUR_VIMEO_VIDEO_URL')) {
// video exists, do stuff
} else {
// video does not exist, do other stuff
}
Hope this helps someone.