Skip to content

Commit

Permalink
change and modification
Browse files Browse the repository at this point in the history
  • Loading branch information
arif98741 committed Jul 6, 2021
1 parent 78a7d3f commit a38d59e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Provider/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function sendRequest()
{
$username = "YOUR_API_USERNAME";
$hash = "YOUR_API_HASH_TOKEN";
$numbers = "017xxxxxxxx,018xxxxxxxx"; //Recipient Phone Number multiple number must be separated by comma
$numbers = "017xxxxxxxx,018xxxxxxxx";
$message = "Simple text message.";


Expand Down
7 changes: 4 additions & 3 deletions src/Provider/GreenWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Xenon\LaravelBDSms\Provider;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Sender;

Expand All @@ -28,7 +29,7 @@ public function __construct(Sender $sender)

/**
* Send Request To Api and Send Message
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function sendRequest()
{
Expand All @@ -37,7 +38,7 @@ public function sendRequest()
$config = $this->senderObject->getConfig();

$client = new Client([
'base_uri' => 'http://esms.dianahost.com/smsapi',
'base_uri' => 'https://api.greenweb.com.bd/api.php?json',
'timeout' => 10.0,
]);

Expand All @@ -53,7 +54,7 @@ public function sendRequest()

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

Expand Down
65 changes: 35 additions & 30 deletions src/Provider/MDL.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Last Modified: 6/28/21, 11:18 PM
* Last Modified: 6/29/21, 12:06 AM
* Copyright (c) 2021
* -created by Ariful Islam
* -All Rights Preserved By
Expand All @@ -11,15 +11,15 @@

namespace Xenon\LaravelBDSms\Provider;


use Xenon\Handler\XenonException;
use GuzzleHttp\Client;
use Illuminate\Http\JsonResponse;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\Sender;
use Xenon\LaravelBDSms\Sender;

class MDL extends AbstractProvider
{
/**
* BulkSmsBD constructor.
* MDL constructor.
* @param Sender $sender
*/
public function __construct(Sender $sender)
Expand All @@ -36,40 +36,45 @@ public function sendRequest()
$text = $this->senderObject->getMessage();
$config = $this->senderObject->getConfig();

$url = "http://premium.mdlsms.com/smsapi";
$data = [
"api_key" => $config['api_key'],
"type" => $config['type'],
"contacts" => $number,
"senderid" => $config['senderid'],
"msg" => $text,
];
$client = new Client([
'base_uri' => 'http://premium.mdlsms.com/smsapi',
'timeout' => 10.0,
]);

$response = $client->request('GET', '', [
'query' => [
'api_key' => $config['api_key'],
'type' => $config['type'],
'senderid' => $config['senderid'],
'contacts' => $number,
'msg' => $text,
]
]);
$body = $response->getBody();
$smsResult = $body->getContents();

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$smsResult = curl_exec($ch);
curl_close($ch);
return $this->generateReport($smsResult, $data);
$data['number'] = $number;
$data['message'] = $text;
$report = $this->generateReport($smsResult, $data);
return $report->getContent();
}

/**
* @throws XenonException
* @throws RenderException
*/
public function errorException()
{
if (!is_array($this->senderObject->getConfig())) {
throw new RenderException('Configuration is not provided. Use setConfig() in method chain');
}

if (!array_key_exists('api_key', $this->senderObject->getConfig())) {
throw new RenderException('api_key is absent in configuration');
}
if (!array_key_exists('type', $this->senderObject->getConfig())) {
throw new RenderException('type key is absent in configuration');
}
if (!array_key_exists('senderid', $this->senderObject->getConfig())) {
throw new RenderException('senderid key is absent in configuration');
}

if (strlen($this->senderObject->getMobile()) > 11 || strlen($this->senderObject->getMobile()) < 11) {
throw new RenderException('Invalid mobile number. It should be 11 digit');
}
Expand All @@ -81,17 +86,17 @@ public function errorException()
/**
* @param $result
* @param $data
* @return array
* @return JsonResponse
*/
public function generateReport($result, $data): array
public function generateReport($result, $data)
{
return [
return response()->json([
'status' => 'response',
'response' => $result,
'provider' => self::class,
'send_time' => date('Y-m-d H:i:s'),
'mobile' => $data['number'],
'message' => $data['message']
];
]);
}
}
5 changes: 3 additions & 2 deletions src/Provider/Onnorokom.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@


use SoapClient;
use Xenon\Handler\XenonException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Handler\XenonException;
use Xenon\Sender;

class Onnorokom extends AbstractProvider
Expand Down Expand Up @@ -72,7 +73,7 @@ public function generateReport($result, $data): array
}

/**
* @throws XenonException
* @throws RenderException
*/
public function errorException()
{
Expand Down

0 comments on commit a38d59e

Please sign in to comment.