Results 1 to 4 of 4
Nov 17, 2012, 01:23 #1
connect to pizza hut validator using CURL
Hi - i'm trying to connect to the pizza hut postcode validator using CURL but it doesn't seem to be working. I have a feeling it has something to do with the headers. Any ideas?
$url = "http://delivery.pizzahut.co.uk/?userpostcode=CM145PP&x=12&y=17";
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Connection: keep-alive", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3"));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
$result = curl_exec($ch);
Guaranteed red hot to your door - We're experiencing problems with our site so please come back soon.
Nov 17, 2012, 06:45 #2
- Join Date
- Apr 2008
- North-East, UK.
- 3 Post(s)
- 0 Thread(s)
That URL performs a redirect (302), and when it does so create/updates the ASP.net cookie referencing the previously supplied postcode. You need to store the cookie so the subsequent request knows what postcode you searched for.
A quick search on "curl php cookies" should bear fruit.
Nov 18, 2012, 12:40 #3
curl_setopt($ch, CURLOPT_COOKIE, "ASP.NET_SessionId=k3zmplax2v1qtc45erxtl5hu; .ASPXAUTH=106B54F85A427924C6930E9F8CF4ECD969F93FAD5FB7A2261B57A03CC541605BCF494C9A61360D360DF7020225F7FA7A944A0E929C4C5519038AAE7487C76EBFC43786D07679E36879CD393A9E4ADFF401B435166ED23A21D5E15FF69A10F3B3CEDBBFB57B26092A8DF696661D44F217C03D32522992E1902EC0AA120E4CD8C87726AF1E11C04F09B69AB2FEE3BB03DD81E3019A; .ASPXANONYMOUS=XPr4-kr8zQEkAAAAZTUyN2Q3YjQtMWJiMC00Y2FjLWI3MGYtYWRiNzlhNjgwMTg0khVyHHjz7kAHmpbD3shVHRYiNcQ1; __utma=193058988.2050382701.1353136223.1353136223.1353262732.2; __utmb=1930589184.108.40.2063262732; __utmc=193058988; __utmz=193058988.1353136223.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)");
Nov 20, 2012, 07:11 #4
I am pretty sure you are doing it wrong. I don't think you should be hard-coding the cookie value to your script. Instead you need to set a path to a file that will store your cookies. CURL will then be able to reuse the previously set cookie, just like the real browser does.
What you need is an option CURLOPT_COOKIEFILEMy project: Open source Q&A
(similar to StackOverflow)
powered by php+MongoDB
Source on github, collaborators welcome!