I have the following cURL command:
curl -i -H "Accept: application/json" -H "Content-Type: application/json; charset=utf-8" -H "TC: 000000" -H "ST: 000000" -X POST -d '[{"Param1" : "Value1", "Param2" : "Value2"} ]' http://www.somesaasprovider.com/
It works fine when I'm running it in the terminal and I get the expected output.
However, when I try to use the same command but adapted to PHP, I get no result.
The PHP version looks like this:
error_reporting(E_ALL);
ini_set('display_errors', '1');
$ch = curl_init('http://www.somesaasprovider.com');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, '[{"Param1" : "Value1", "Param2" : "Value2"}]');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json; charset=utf-8',
'TC' => '000000',
'ST' => '000000')
);
$response = curl_exec($ch);
$response = json_decode($response);
print_r($response);
What am I doing wrong?
Thanks.