following a redirect, reading a remote webpage.

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
heygrady
Forum Newbie
Posts: 1
Joined: Mon Feb 23, 2004 5:06 am

following a redirect, reading a remote webpage.

Post by heygrady »

am writing a script that reads a remote webpage, parses the links and displays the page with altered links. The idea of the script is to allow my users to surf the web from my website while I record what they do as part of a strange game I have concocted.

The problem is this, I can get the page to load from a remote source with altered links but once I follow the link I have no idea how to find out where I am. This is especially true if the link I followed is a redirected url as is common on the yahoo homepage.

So, if I click on a link like http://www.yahoo.com/s/42481, it will take me to sports.yahoo.com/ncaab. Is there a way in PHP to determine that http://www.yahoo.com/s/42481 redirects to sports.yahoo.com/ncaab?

I need to be able to follow a redirect and return the destination programatically using php. I need to write a function that works like this:

Code: Select all

function followRedirect ($given_url){ 
[some php magic] 
return $redirected_url; 
}
Can anyone help me??
Post Reply