Bonjour,
J'arrive à envoyer des sms via l'utilisation de l'api. Cependant, je n'arrive pas à pouvoir limiter l'envoi de sms à un quota. Je suppose qu'il y a un soucis avec ma configuration, côté liaison entre interface web et api.
Pour cela, j'ai bien créé un utilisateur via le panneau d'administration d'OVH (Gestion des utilisateurs), auquel j'ai affecter un quota de deux SMS pour mes tests + alerte à 1 par email.
Côté code, deux choses :
- Récupération du quota restant pour le compte utilisateur (web). Cela fonctionne (je suppose), mais vu que je n'arrive pas à avoir de quota qui se décrémente, j'ai tous le temps la même valeur.
```php
$quota = $this->api->get('/sms/'.$this->service.'/users/'.$this->accountLogin)["quotaInformations"]["quotaLeft"];
```
- Envoi Sms (fonctionnel) avec pour sender l'utilisateur créé.
```php
$content = (object) array(
'charset' => 'UTF-8', // The sms coding (type: sms.CharsetEnum)
'class' => 'phoneDisplay', // The sms class (type: sms.ClassEnum)
'coding' => '7bit', // The sms coding (type: sms.CodingEnum)
'differedPeriod' => NULL, // The time -in minute(s)- to wait before sending the message (type: long)
'message' => $message, // The sms message (type: string)
'noStopClause' => false, // Do not display STOP clause in the message, this requires that this is not an advertising message (type: boolean)
'priority' => 'high', // The priority of the message (type: sms.PriorityEnum)
'receivers' => $listToSend, // The receivers list (type: string)
'receiversDocumentUrl' => NULL, // The receivers document url link in csv format (type: string)
'receiversSlotId' => NULL, // The receivers document slot id (type: string)
'sender' => $this->accountLogin, // The sender (type: string)
'senderForResponse' => false, // Set the flag to send a special sms which can be reply by the receiver (smsResponse). (type: boolean)
'tag' => NULL, // The identifier group tag (type: string)
'validityPeriod' => '2880', // The maximum time -in minute(s)- before the message is dropped (type: long)
);
return $this->api->post('/sms/'. $this->service . '/jobs', $content);
```
Merci de votre compréhension et en attente de vos retours ![]()
Ticket à clore.
Au final, cela venait de ma fonction d'envoi du sms qui devait être modifiée:
```php
return $this->api->post('/sms/'. $this->service . '/users/'.$this->accountLogin.'/jobs', $content);
```