SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

    PHP Code:
    $url "http://delivery.pizzahut.co.uk/?userpostcode=CM145PP&x=12&y=17";
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
            
    curl_setopt($chCURLOPT_HTTPHEADER, array("Connection: keep-alive""Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3"));
            
    curl_setopt($chCURLOPT_URL$url);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($chCURLOPT_AUTOREFERER1);
            
    $result curl_exec($ch);
            
    print_r($result);
            
    curl_close($ch); 
    I get the result:

    Code:
    Guaranteed red hot to your door - We're experiencing problems with our site so please come back soon.

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    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.

    Anthony.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    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.

    Anthony.
    Hi - so I added the following line to the request, but still getting the same issue. Is there something else I need to do?

    PHP Code:
            curl_setopt($chCURLOPT_COOKIE"ASP.NET_SessionId=k3zmplax2v1qtc45erxtl5hu; .ASPXAUTH=106B54F85A427924C6930E9F8CF4ECD969F93FAD5FB7A2261B57A03CC541605BCF494C9A61360D360DF7020225F7FA7A944A0E929C4C5519038AAE7487C76EBFC43786D07679E36879CD393A9E4ADFF401B435166ED23A21D5E15FF69A10F3B3CEDBBFB57B26092A8DF696661D44F217C03D32522992E1902EC0AA120E4CD8C87726AF1E11C04F09B69AB2FEE3BB03DD81E3019A; .ASPXANONYMOUS=XPr4-kr8zQEkAAAAZTUyN2Q3YjQtMWJiMC00Y2FjLWI3MGYtYWRiNzlhNjgwMTg0khVyHHjz7kAHmpbD3shVHRYiNcQ1; __utma=193058988.2050382701.1353136223.1353136223.1353262732.2; __utmb=193058988.1.10.1353262732; __utmc=193058988; __utmz=193058988.1353136223.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)"); 

  4. #4
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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_COOKIEFILE
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •