Mimicking an ajax call with Curl PHP Mimicking an ajax call with Curl PHP curl curl

Mimicking an ajax call with Curl PHP


To set the request verification token as a header, more closely mimic an AJAX request, and set the content-type to JSON, use CURLOPT_HEADER.

curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest", "Content-Type: application/json; charset=utf-8", "__RequestVerificationToken: $token"));

I also notice that you're superfluously setting CURLOPT_POST to false on line 7 of your code, and that the post data you're sending isn't in JSON format. You should have:

$postVariables = '{"historyPageIndex":1,"displayPeriod":0,"productsType":"All"}';