SUNU CAISSE
Documentation API
Envoi de SMS (cURL)
Envoyez des messages instantanément via une simple requête HTTP POST vers l'endpoint de l'API.
curl -X POST ".../api.php?action=send" \ -H "Authorization: Basic $(echo -n '...:...' | base64)" \ -H "Content-Type: application/json" \ -d '{"to": "+221770000000", "message": "Ceci est un message de test", "sender": "SUNU CAISSE"}'
Paramètres
| Paramètre | Type | Description |
|---|---|---|
action |
String | Dans l'URL: ?action=send |
to |
String | Numéro du destinataire (format international recommandé, ex: +221770000000) |
message |
String | Contenu du SMS à envoyer |
sender |
String | (Optionnel) ID de l'expéditeur (max 11 caractères) |
Exemple en PHP
<?php $url = '.../api.php?action=send'; $api_key = '...'; $api_secret = '...'; $data = array( 'to' => '+221770000000', 'message' => 'Bonjour, ceci est un test de SUNU CAISSE SMS!', 'sender' => 'SUNU CAISSE' ); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$api_secret"); $response = curl_exec($ch); curl_close($ch); echo $response; ?>