cyfer65 Posted July 19, 2011 Share Posted July 19, 2011 How come this will work... <?phpecho file_get_contents('http://whatismyip.org/');?> But this wont..? <?phpecho file_get_contents('http://tinyurl.com/yardhc');?> the tinyurl just forwards to http://whatismyip.org/why doesn't it follow through to the forwarded site to get its contents..?What else can i do to make it work using the tinyurl..? Link to comment Share on other sites More sharing options...
Ingolme Posted July 19, 2011 Share Posted July 19, 2011 How come this will work...<?phpecho file_get_contents('http://whatismyip.org/');?> But this wont..? <?phpecho file_get_contents('http://tinyurl.com/yardhc');?> the tinyurl just forwards to http://whatismyip.org/why doesn't it follow through to the forwarded site to get its contents..?What else can i do to make it work using the tinyurl..? That's because what tinyurl does is send a location header to the client which contains the URL that the client must redirec to. You would need to use cURL to read the response header and have your program use file_get_contents on the URL that's found in that header. Link to comment Share on other sites More sharing options...
Synook Posted July 19, 2011 Share Posted July 19, 2011 Basically, file_get_contents() doesn't follow the redirect, like more advanced libraries such as cURL can. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.