i am working on SmallInvoice api . here is the link
smallinvoice.ch/api/general/overview
i am trying to add a client in small invoice account . here is the code
$url = 'https://api.smallinvoice.com/client/add/token/MyTokenIsHere';
$address[] = array(
"street" => "Address",
"streetno" => "",
"code" => 60000,
"city" =>"Multan",
"country" => "PK"
);
$this->data['add_client'] = array(
"type" => 2,
"gender" => 1,
"name" => "Adnan Ahmad",
"language" => "en",
"number" => 5,
"addresses" => $address
);
$json_add_client = json_encode($this->data['add_client']);
// curl request start
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_POSTFIELDS,$json_add_client);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION ,1);
curl_exec($handle);
// curl request end
here is the curl response
{"error":true,"errorcode":0,"errormessage":"The datastream provided is not valid or empty"}
when i print $json_add_client variable data looks like this
{"type":2,"gender":1,"name":"Adnan Ahmad","language":"en","number":5,"addresses":[{"street":"Address","streetno":"","code":60000,"city":"Multan","country":"PK"}]}
i copied above json data and paste small invoice test api .. (here is the link where i paste)
http://www.smallinvoice.ch/api/testapi/clients
At this time client has been added successfully .
I DON'T KNOW WHY CLIENT IS NOT ADDING THROUGH CURL REQUEST .
if any body knows then please tell me where i m mistaking . i'll be grateful to you .