Following redirect to a second URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jakejarvis
Forum Newbie
Posts: 1
Joined: Sun Apr 22, 2007 8:25 pm

Following redirect to a second URL

Post by jakejarvis »

Hi all,

I'm developing a site relating to YouTube videos. I currently have a function that retrieves the YouTube FLV URL. For example:

http://www.youtube.com/get_video?video_ ... 9Ia-RxuCoh

However, this URL redirects to another URL that is the true location of the video file. For example, the above URL redirects to:

http://lax-v158.lax.youtube.com/get_vid ... C71t8GzqPs

My Flash applet does not work if the function returns the non-redirected URL. Is there any way to make a function that follows the first URL and returns the true location of the video file (the second URL)?

Thanks in advance for any help.
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

A few notes... The redirected location is not going to be the "true" location of the file, it's routing you through a server to control the server loads. View the same video 3 or 4 times and you may get 3 or 4 different redirected paths. So, the URL you should bookmark is the one that YouTube gives to you in the first place.

Also, this is a PHP forum, so for a better response to your flash related question, you may want to try a flash forum.
Post Reply