Create contact with API in PHP

Create contact with API in PHP

Hi,

I try to create a new contact in Zoho Invoice from a custom application. I make this code (take on Internet) :

$param = array(
'contact_name'=>$_POST['nom'],
'company_name'=>$_POST['nom']
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param));
$result = curl_exec($ch);
print_r(json_decode($result));
curl_close($ch);

But it return this :  stdClass Object ( [code] => 4 [message] => Invalid value passed for JSONString )
$_POST['nom'] is equal to 'test'

It my first REST application in PHP and I'm a little bit lost :p.
If anyone can help me.

Thank you.