PHP: Capture Location of FLV from YouTube


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $url = trim($_REQUEST['url']);
  3. if (strpos($url, 'http://www.youtube.com/watch?v=') === 0)
  4. {
  5. $ch = curl_init();
  6.  
  7. curl_setopt($ch, CURLOPT_URL, $url);
  8. curl_setopt($ch, CURLOPT_HEADER, false);
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  10.  
  11. $info = curl_exec($ch);
  12.  
  13. $pos1 = strpos($info, "&amp;video_id=", $pos1);
  14. $pos2 = strpos($info, "&amp;t=", $pos2);
  15.  
  16. $video_id = substr($info, $pos1 + 10, 11);
  17. $tag_t = substr($info, $pos2 + 3, 32);
  18.  
  19. $response = '';
  20. $response .= '' . $video_id . '';
  21. $response .= '' . $tag_t . '';
  22. $response .= '';
  23.  
  24. header("Content-type: text/xml");
  25. echo $response;
  26.  
  27. curl_close($ch);
  28. } else
  29. {
  30. die("Wrong URL / Parameters");
  31. }
  32. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.