I'm new to PHP. I'm trying to write a file which sends a POST request to an API with specific json data and headers.
This is what I am trying to replicate:
This is my PHP code:
$url = 'http://api.local/rest/users';
$data = '{"4":"four","8":"eight"}';
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json','Authorization: Bearer ACCESSTOKEN','x-api-key: APIKEY,'x-proxy-global-company-id: COMPANYID'));
$result=curl_exec($ch);
This results in the following error:
unexpected 'x' (T_STRING), expecting ')' in your code on line 9
As far as I can see I have closed out my brackets on the array correctly. Could anyone please give a novice PHP programmer a bit of help on this one please.