tags:

views:

70

answers:

2

Hi

My web hosting provider does not permit to use curl FOLLOWLOCATION option so I'm trying to do it manually by using the header function.

My problem is that I need to keep my PHP script running and to be able to get the redirected URL data for parsing.

How do I do that?

+1  A: 

Technically the PHP script continues running after the header () function is called. How you get URL data is another question. Can you not use get_file_contents () or readfile () on the URL?

DCD
A: 

You read the RAW data the request returns, you check for the redirect header(s), fetch the related URL(s) and do a new get with that URL (dry, rinse, repeat). As simple as that...

Alternatively you could stop being so lazy, check the curl_setopt documentation in the PHP reference manual and find solutions - by reading the comments at the bottom of the page - on how to solve this problem of course.

wimvds
I did read the curl_setopt doc.Things would be more easy if I could use the FOLLOWLOCATION option.I'll try to redirect manually using header and than read and parse the HTML content of redirected URL.
embedded
Then you didn't read the comments (I specifically told you to read these, didn't I?), because there are functions there that you can copy/paste that will do exactly what you want.
wimvds
BTW They're here : http://www.php.net/curl_setopt#95943 or http://www.php.net/curl_setopt#95027 (just found out that they include anchors in the comments). The first one will also cover HTML META redirects, so probably is better then the second one.
wimvds