Skip to content

Commit

Permalink
Merge branches 'master' and 'dev' of github.com:arif98741/laravelbdsms
Browse files Browse the repository at this point in the history
  • Loading branch information
arif98741 committed Sep 18, 2024
2 parents 3df7af3 + fd806df commit ea137f5
Showing 5 changed files with 121 additions and 9 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -210,7 +210,10 @@ echo $status = $sender->send();
| OnnoRokomSMS | userName, userPassword, type, maskName, campaignName | - | Done | not tested yet in live | - |
| QuickSms | api_key, senderid, type,scheduledDateTime | - | Done | not tested yet in live | - |
| RedmoITSms | api_token, sender_id | - | Support closed | - |
| RedmoITSms | api_token, sender_id | - | Support closed | - |
| SmartLabSMS | user, password, sender | - | Done | - | - |
| Sms4BD | publickey, privatekey, type,sender, delay | - | Done | - | - |
| SmsBangladesh | user, password, from | - | Done | - | - |
| SmsinBD | api_token, senderid | - | Done | | - |
| SMS.net.bd | api_key | - | Done | | - |
| SmsQ | sender_id, client_id, api_key | - | Done | | - |
6 changes: 6 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
use Xenon\LaravelBDSms\Provider\RedmoItSms;
use Xenon\LaravelBDSms\Provider\SmartLabSms;
use Xenon\LaravelBDSms\Provider\Sms4BD;
use Xenon\LaravelBDSms\Provider\SmsBangladesh;
use Xenon\LaravelBDSms\Provider\SmsinBD;
use Xenon\LaravelBDSms\Provider\SmsNet24;
use Xenon\LaravelBDSms\Provider\SmsNetBD;
@@ -246,6 +247,11 @@
'sender' => env('SMS_SMS4BD_SENDER', ''),
'delay' => env('SMS_SMS4BD_DELAY', ''),
],
SmsBangladesh::class => [
'user' => env('SMS_BANGLADESH_USER', ''),
'password' => env('SMS_BANGLADESH_PASSWORD', ''),
'from' => env('SMS_BANGLADESH_FROM', ''),
],
SmsNet24::class => [
'user_id' => env('SMS_SMSNET24_USER_ID', ''),
'user_password' => env('SMS_SMSNET24_USER_PASSWORD', ''),
25 changes: 18 additions & 7 deletions src/Provider/SmartLabSms.php
Original file line number Diff line number Diff line change
@@ -14,12 +14,13 @@
use GuzzleHttp\Exception\GuzzleException;
use Xenon\LaravelBDSms\Handler\ParameterException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Helper\Helper;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

class SmartLabSms extends AbstractProvider
{
private string $apiEndpoint = 'https://labapi.smartlabsms.com/smsapi';
private string $apiEndpoint = 'https://labapi.smartlabsms.com';

/**
* SmartLabSMS constructor.
@@ -36,23 +37,33 @@ public function __construct(Sender $sender)
*/
public function sendRequest()
{
$number = $this->senderObject->getMobile();
$mobile = $this->senderObject->getMobile();
$text = $this->senderObject->getMessage();
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries=$this->senderObject->getTries();
$backoff=$this->senderObject->getBackoff();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();

$query = [
'user' => $config['user'],
'password' => $config['password'],
'sender' => $config['sender'],
'msisdn' => $number,
'smstext' => $text,
];

$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
if (!is_array($mobile)) {
$this->apiEndpoint .= '/smsapi';
$query['msisdn'] = Helper::ensureNumberStartsWith88($mobile);
} else {
$this->apiEndpoint .= '/smsapiv2';
foreach ($mobile as $element) {
$tempMobile[] = Helper::ensureNumberStartsWith88($element);
}
$query['msisdn'] = implode(',', $tempMobile);
}

$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff);
$response = $requestObject->get();
if ($queue) {
return true;
@@ -61,7 +72,7 @@ public function sendRequest()
$body = $response->getBody();
$smsResult = $body->getContents();

$data['number'] = $number;
$data['number'] = $mobile;
$data['message'] = $text;
return $this->generateReport($smsResult, $data)->getContent();
}
94 changes: 94 additions & 0 deletions src/Provider/SmsBangladesh.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace Xenon\LaravelBDSms\Provider;

use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Helper\Helper;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

class SmsBangladesh extends AbstractProvider
{
private string $apiEndpoint = 'https://panel.smsbangladesh.com/api';

/**
* SmsBangladesh Constructor
* @param Sender $sender
* @version v1.0.32
* @since v1.0.31
*/
public function __construct(Sender $sender)
{
$this->senderObject = $sender;
}

/**
* @return false|string
* @throws RenderException
* @version v1.0.32
* @since v1.0.31
*/
public function sendRequest()
{
$mobile = $this->senderObject->getMobile();
$text = $this->senderObject->getMessage();
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();

$formParams = [
"user" => $config['user'],
"password" => $config['password'],
"from" => $config['from'],
"text" => urlencode($text),
];

if (!is_array($mobile)) {
$formParams['to'] = Helper::ensureNumberStartsWith88($mobile);
} else {
foreach ($mobile as $element) {
$tempMobile[] = Helper::ensureNumberStartsWith88($element);
}
$formParams['to'] = implode(',', $tempMobile);
}

$requestObject = new Request($this->apiEndpoint, [], $queue, [], $queueName, $tries, $backoff);
$requestObject->setFormParams($formParams);
$response = $requestObject->post(false, 60);
if ($queue) {
return true;
}


$body = $response->getBody();
$smsResult = $body->getContents();

$data['number'] = $mobile;
$data['message'] = $text;
return $this->generateReport($smsResult, $data)->getContent();
}

/**
* @throws RenderException
* @version v1.0.32
* @since v1.0.31
*/
public function errorException()
{
$config = $this->senderObject->getConfig();

if (!array_key_exists('user', $config)) {
throw new RenderException('user key is absent in configuration');
}

if (!array_key_exists('password', $config)) {
throw new RenderException('password key is absent in configuration');
}

if (!array_key_exists('from', $config)) {
throw new RenderException('from key is absent in configuration');
}
}
}
2 changes: 0 additions & 2 deletions src/Sender.php
Original file line number Diff line number Diff line change
@@ -244,7 +244,6 @@ public function send()
}
}


$this->provider->errorException();

$config = Config::get('sms');
@@ -329,7 +328,6 @@ public function getProvider()
*/
public function setProvider($providerClass): Sender
{

try {

if (!class_exists($providerClass)) {

0 comments on commit ea137f5

Please sign in to comment.