spinet spinet - 3 months ago 12
JSON Question

How to add Content-Type application/json in this request

I need to send this Content-Type - application/json in headers of the request below.
How to add Content-Type application/json in this function in a head's array?

function sendOrder($arField){

$body='{
}';

$head=array("Authorization: ".$data['scheme']." ".$data['token']);
$data=self::getData("https://example.com",$body,$head);
return $data;
}

Answer

Replacing the existing line with:

$head=array("Authorization: ".$data['scheme']." ".$data['token'], "Content-Type: application/json");

Should be all you need to do.

Comments