diff --git a/src/Config/sms.php b/src/Config/sms.php index a9b5372..e138dc2 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -291,6 +291,7 @@ 'api_token' => env('SMS_SSL_API_TOKEN', ''), 'sid' => env('SMS_SSL_SID', ''), 'csms_id' => env('SMS_SSL_CSMS_ID', ''), + 'batch_csms_id ' => env('SMS_SSL_BATCH_CSMS_ID ', ''), ], Tense::class => [ 'user' => env('SMS_TENSE_USER', ''), diff --git a/src/Provider/BulkSmsBD.php b/src/Provider/BulkSmsBD.php index 85b2594..ae24262 100644 --- a/src/Provider/BulkSmsBD.php +++ b/src/Provider/BulkSmsBD.php @@ -55,6 +55,10 @@ public function sendRequest() $query ['senderid'] = $config['senderid']; } + if (is_array($number)) { + $query['number'] = implode(',', $number); + } + $requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff); $response = $requestObject->get(); if ($queue) { @@ -78,5 +82,11 @@ public function errorException() throw new ParameterException('api_key key is absent in configuration'); } + if (!array_key_exists('senderid', $this->senderObject->getConfig())) { + throw new ParameterException('senderid key is absent in configuration'); + } + + + } } diff --git a/src/Provider/Esms.php b/src/Provider/Esms.php index d7ab585..54ad56c 100644 --- a/src/Provider/Esms.php +++ b/src/Provider/Esms.php @@ -18,6 +18,7 @@ class Esms extends AbstractProvider { + private string $apiEndpoint = 'https://login.esms.com.bd/api/v3/sms/send'; /** * DianaHost constructor. * @param Sender $sender @@ -52,7 +53,7 @@ public function sendRequest() 'Content-Type' => 'application/json' ]; - $requestObject = new Request('https://login.esms.com.bd/api/v3/sms/send', $query, $queue, [], $queueName,$tries,$backoff); + $requestObject = new Request($this->apiEndPoint, $query, $queue, [], $queueName,$tries,$backoff); $requestObject->setHeaders($headers)->setContentTypeJson(true); $response = $requestObject->post(); if ($queue) { diff --git a/src/Provider/Ssl.php b/src/Provider/Ssl.php index 7c29284..ffc5082 100644 --- a/src/Provider/Ssl.php +++ b/src/Provider/Ssl.php @@ -45,12 +45,17 @@ public function sendRequest() $query = [ 'api_token' => $config['api_token'], 'sid' => $config['sid'], - 'csms_id' => $config['csms_id'], 'msisdn' => $mobile, + 'csms_id' => $config['csms_id'], 'sms' => $text, + 'batch_csms_id' => $config['batch_csms_id'] ?? null, ]; $requestObject = new Request($this->apiEndpoint . (is_array($mobile) ? '/bulk' : ''), $query, $queue, [], $queueName, $tries, $backoff); + $requestObject->setHeaders([ + 'Content-Type' => 'application/json', + ])->setContentTypeJson(true); + $response = $requestObject->post(); if ($queue) { return true; @@ -79,5 +84,9 @@ public function errorException() throw new RenderException('csms_id key is absent in configuration'); } + if (is_array($this->senderObject->getMobile()) && !array_key_exists('batch_csms_id', $this->senderObject->getConfig())) { + throw new RenderException('batch_csms_id key is absent in configuration. This is required if you send array of receivers'); + } + } }