I need to convert this PHP proxy script to ASP:
<?
if (isset($_GET['image'])) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_GET['image']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
curl_close($ch);
header("Content-type: image/jpeg");
header("Content-Length: " . strlen($str));
echo $str;
}
else {
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: text/xml");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "
http://www.youtube.com/watch_video?v=" . $_GET['id']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$header = curl_exec($ch);
curl_close($ch);
$vpos = strpos($header, '?video_id=');
if ($vpos) {
$header = substr($header, $vpos + 10);
$video_id = substr($header, 0, strpos($header, "&"));
$header = substr($header, strpos($header, '&iurl=') + 6);
$iurl = substr($header, 0, strpos($header, '&'));
$header = substr($header, strpos($header, '&t=') + 3);
$t = substr($header, 0, strpos($header, chr(13)));
echo '<xml><video video_id="'.$video_id.'" iurl="'.$iurl.'" t="'.$t.'" /></xml>';
}
else {
echo '<xml><message error="Bad URL." /></xml>';
}
}
?>
Start Free Trial