Forum Moderators: coopster
How can I make sure that the provided URL is really for a video? (eg I don't want them to be able to submit a link to a YouTube user profile page) I want to support a wide range of video sites so I can't just search the provided url for "watch?v=" (for a YouTube video). I need to actually verify the URL is for a video.
I found something here but it only seems to verify the base domain, and not the specific URL.
Any ideas? Thanks!
[edited by: coopster at 2:10 am (utc) on Sep. 23, 2007]
[edit reason] removed url TOS [webmasterworld.com] [/edit]
EDIT------------
I'm trying this code:
<?php
// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.youtube.com/watch?v=00000000");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL
$output = curl_exec($ch);
// Get response code
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Not found?
if ($response_code == '404') {
echo 'Page doesn\'t exist';
} else {
echo $output;
}
?>
The URL is not a valid YouTube video but the script prints "1". What does 1 mean?