// Ouvre la connexion cURL
$curl = curl_init();
// URL d'appel
$url = 'https://login:password@app.avizi.fr/api/services/v2/request/new/request';
// 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(
'contact' => array (
'firstname' => 'string',
'lastname' => 'string',
'company' => 'string',
'street' => 'string',
'postal_code' => 'string',
'city' => 'string',
'country_number' => 'integer',
'language_number' => 'integer',
'mail' => 'mail',
'phone' => 'numeric',
'fixe' => 'numeric',
'title_number' => 'integer',
'is_pro' => 'boolean',
'optin_mail' => 'boolean',
'optin_sms' => 'boolean',
'cycle_of_stay' => 'boolean',
'campaigns' => 'array',
'optins' => array (
array (
'id' => 'integer',
'mode_campaign' => 'integer',
'criteria' => array (
array (
'id' => 'integer',
'value' => 'string',
)
)
),
'thematics' => 'array',
'profil_number' => 'integer',
'profil_quantity' => 'integer',
'request_country_number' => 'integer',
'contact_number' => 'integer',
'response_number' => 'integer',
'visit_date' => 'datetime',
'presence_start_date' => 'date',
'presence_end_date' => 'date',
'confirmation' => 'boolean',
'private_note' => 'string',
'public_note' => 'string',
'mode_payment_number' => 'integer',
'payment_status' => 'boolean',
'website_origin' => 'string',
'sit_locale' => 'string',
'products' => array (
array (
'version_number' => 'integer',
'sit_number' => 'integer',
'sit_type_id' => 'integer',
'quantity' => 'integer',
'discount' => 'float',
'send_mode_number' => 'integer',
'criteria' => array (
array (
'id' => 'integer',
'value' => 'string',
)
)
);
// 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);