So your script, will be like this one:
include 'SplynxApi.php';
$api_url = 'http://xxxxxxxx/'; // please set your Splynx URL
$key = "xxxxxxxxxx"; // please set your key
$secret = "xxxxxxxxxxx"; // please set your secret
// don't forget to add permissions to API Key, for changing locations.
$api = new SplynxAPI($api_url, $key, $secret);
$locationsApiUrl = "admin/administration/locations";
$customersApiUrl = "admin/customers/customer?" . http_build_query($search);
$urlCustom = "admin/customers/customer";
print "Create Customers\n";
$result = $api->api_call_post($customersApiUrl,
array(
'name' => $firstname . ' ' . $surname,
'category' => 'person',
'phone' => $phone,
'email' => $email,
'location_id' => $location,
'partner_id' => '1',
'street_1' => $street,
'zip_code' => $zipcode,
'city' => $city,
'status' => 'active'
));
print "Result: ";
if ($result) {
print "Ok!\n";
print_r($api->response);
$customer_id = $api->response['id'];
} else {
print "Fail! Error code: $api->response_code\n";
print_r($api->response);
$customer_id = false;
}
$data = [
'main_attributes' => [
'id' => $customer_id
]
];
$api->api_call_get($urlCustom.'?'.http_build_query($data));
$curent_customer = $api->response;
$customer_login = $curent_customer[0]['login'];
$data_array = array(
'customer_id' => $customer_id,
'tariff_id' => 'tariff_id',
'description' => 'tariff name',
'quantity' => '1',
'status' => 'active',
'unit_price' => '20.0',
'start_date' => '2017-06-01',
'end_date' => '0000-00-00',
'login' => $customer_login
);
$result = $api->api_call_post($urlCustom.'/'.$customer_id.'/internet-services', $data_array);
if ($result) {
//some action;
} else {
//some action;
}