Closed pedmindset closed 5 years ago
Hi!
You can use the SendMultipleTextualSmsAdvanced client. It accepts request model which allows you to specify a list of messages, each with its own destination number and message text.
For more info on the advanced SMS endpoint see API documentation.
Thanks for the response, I get it now so rather than use the setDestinations, i use setTo and create a message array.. like so
`<?php
namespace App\Channel\Infobip;
use infobip\api\client\SendMultipleTextualSmsAdvanced; use infobip\api\configuration\BasicAuthConfiguration; use infobip\api\model\sms\mt\send\Message; use infobip\api\model\sms\mt\send\textual\SMSAdvancedTextualRequest;
class MultipleSmsMessages {
// Initializing SendSingleTextualSms client with appropriate configuration
private $client;
// response
public $response;
//body
private $requestBody;
public function __construct($from, $contents)
{
$this->client = new SendMultipleTextualSmsAdvanced(new BasicAuthConfiguration(config('infobip.username'), config('infobip.password')));
$this->requestBody = new SMSAdvancedTextualRequest();
$this->requestBody->setMessages($this->messages($contents));
// Executing response
$this->response = $this->client->execute($this->requestBody);
}
/**
* Creates message object for each phone number and text in the array
*
* @param array $content
* @return infobip\api\model\sms\mt\send\Message
*/
private function messages($contents)
{
//A message object is created for each phone number:
$messages = array();
foreach ($contents as $content) {
//Set Message array
$message = new Message();
$message->setFrom($content['from']);
$message->setTo($content['to']);
$message->setText($content['text']);
$messages[] = $message;
}
return $messages;
}
}`
wanted to find out, if its possible to pass an array to setText() on the Message Class when sending to multiple number so the first number receives the first message in the message array..
if not possible, how do i implement this since its in your http api docs