Advertisement

09.29.2008 at 12:01PM PDT, ID: 23772506 | Points: 500
[x]
Attachment Details

Convert PHP to ASP

Asked by oksum73 in Active Server Pages (ASP), PHP Scripting Language

Tags:

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
[+][-]09.29.2008 at 12:13PM PDT, ID: 22599579

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 01:05PM PDT, ID: 22600099

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 01:14PM PDT, ID: 22600193

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 01:24PM PDT, ID: 22600284

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628