API INVOICE ADD

I cant add an invoice with the api.
I use curl in php for my school project.
Does somebody see something wrong in this?

$arrayproduct = array(“product_key” => “ITEM”, “notes”=> “TEST” , “cost”=> 15, “qty” => 1);

            $arr  = array("client_id" => $client_id, "invoice_items" => $arrayproduct);

            $arrjson = json_encode($arr);

                $ch = curl_init('localhost/ninja/public/api/v1/invoices');                                                                      
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                curl_setopt($ch, CURLOPT_POSTFIELDS, $arrjson);                                                                  
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                    'Content-Type: application/json',                                                                                
                    'Content-Length: ' . strlen($arrjson),
                    'X-Ninja-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxx',
                ));
              $result = curl_exec($ch);

You may want to use the PHP SDK, it makes things a bit easier.

https://github.com/invoiceninja/sdk-php

invoice_items should be an array of arrays/objects

oke but now it gives me thins one when i use the php sdk.

Fatal error: Uncaught Error: Class ‘InvoiceNinja\Config’ not found in C:\xamp3\htdocs\ninja\callapiaddklant.php:6 Stack trace: #0 {main} thrown in C:\xamp3\htdocs\ninja\callapiaddklant.php on line 6

is this problem with composer not installed like it should or …?

Not sure, hard to say… have the files been downloaded by composer?

Now the problem is that when I run this code
$client = new Client(‘pierrot.janson@example.com’, ‘pierrot’, ‘janson’ , ‘pierrot janson’);
$client->createInvoice();
$client->save();
$invoice = $client->createInvoice();
$invoice->addInvoiceItem(‘ITEM’, 'HotelReservatie ', 150, 1);
$invoice->save();

He makes two clients, but i want that when it makes a client and an invoice at the same time .
Is it possible?

You have an extra call to createInvoice() but I don’t think it should have an effect.