So I am building a script in PHP which submit datas to a third-party site using a HTTP POST request via Curl. I have been successful in getting this to work with 4 pages so far, however there is one which doesn't want to play.
I have used HTTPTrack in Chome to track exactly what POST data is submitted when the action is performed in the browser. I have also successfully manually posted this data back using HTTPRequester in Firefox and the site return "200 OK" and accepts the request and processes the data.
However when the exact same request is made in Curl, it returns a "200 OK", but doesn't process the data. I have tracked the HTTP POST in tcpdump on the server and it is identical to that submitted by Chome and manually in Firefox. Also the method used to submit the data is the same in the other 4 scripts which do work so I don't believe this is something code related as such.
But I am missing something and I am not sure what, any ideas?
Code as requested...
// Send post data
$url = "http://www.thesite.com/user.aspx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/home/site/cookies/c.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/home/site/cookies/c.txt');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
//curl_setopt($ch, CURLOPT_HEADER, true);
//curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$html = curl_exec($ch);