Last active
February 9, 2019 03:42
-
-
Save Rodgath/afed82d572f4c22f76c14548ac50b349 to your computer and use it in GitHub Desktop.
Check if Vimeo video exists or is playable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* 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 | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment