// Ouvre la connexion cURL
$curl = curl_init();
// URL d'appel
$url = 'https://login:password@app.avizi.fr/api/services/reservations/new/reservation';
// Gestion de l'URL, de la méthode HTTP et du retour
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Définition des paramètres
$data = array(
'customer' => array (
'firstname' => 'string',
'lastname' => 'string',
'company' => 'string',
'address' => 'string',
'postal_code' => 'number',
'city' => 'string',
'country_number' => 'integer',
'mail' => 'string',
'phone' => 'number',
'title_number' => 'integer',
'is_pro' => 'boolean',
'optin_mail' => 'boolean',
'optin_sms' => 'boolean',
),
'reservation' => array (
'reservation_number' => 'string',
'status' => 'integer',
'reservation_datetime' => 'datetime',
'items' => array (
array (
'item_number' => 'string',
'name' => 'string',
'description' => 'string',
'SIT_number' => 'string',
'start_date' => 'date',
'end_date' => 'date',
'postal_code' => 'number',
'city' => 'string',
'price' => 'float',
'people_number' => 'integer',
'quantity' => 'integer',
'breakfast' => 'boolean',
'animal' => 'boolean',
'reservation_type_number' => 'integer',
'prestation_type_number' => 'integer',
)
)
);
// Convertion du tableau en JSON
$dataJson = json_encode($data);
// Ajout des paramètres
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataJson);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: '.strlen($dataJson))
);
// Execute la requête cURL
$response = curl_exec($curl);
// Affichage du résultat
print_r($response);
// Ferme la connexion cURL
curl_close($curl);