Converting header data into cURL
Here is the captured header information:
POST /testing/validate HTTP/1.1 Host: test.guysthatcode.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0 Accept: */* Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Referer: http://test.guysthatcode.com/testing Content-Length: 40 Cookie: testcookie=1; Pragma: no-cache Cache-Control: no-cache testToken=sd8f97dgh3jk43oi&code=password
And here is my code attempt right now.
$ch = curl_init("http://test.guysthatcode.com/testing/validate");
$data ="testToken=sd8f97dgh3jk43oi&code=password");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Host" => "test.guysthatcode.com",
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0",
"Accept" => "*/*",
"Accept-Language" => "en-us,en;q=0.5",
"Accept-Encoding" => "gzip, deflate",
"Connection" => "keep-alive",
"Content-Type" => "application/x-www-form-urlencoded; charset=UTF-8",
"Content-Length" => "40",
"X-Requested-With" => "XMLHttpRequest",
"Referer" => "http://test.guysthatcode.com/testing"
));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$result = curl_exec($ch);
echo $result;
The code above returns nothing even though it should have returned a "success!" message. Also, the testToken thing. If the testToken doesn't equal what I have right now, the page will redirect to an error page, but if the testToken does equal what I have, it will display the success message.
Any ideas?
Thanks.






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None
















Help