Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MianSaleem committed Mar 22, 2018
1 parent 23c0e41 commit f210a7d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 76 deletions.
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
],
"require": {
"php": ">=7.0.28",
"guzzlehttp/guzzle": "^6.3@dev",
"monolog/monolog": "^2.0@dev",
"brick/phonenumber": "dev-master"
"guzzlehttp/guzzle": "^6.3.0",
"monolog/monolog": "^1.23.0",
"brick/phonenumber": "^0.2.0"
},
"autoload": {
"psr-4": {
"Tecdiary\\Sms\\": "src/"
}
},
"minimum-stability": "dev"
}
}
96 changes: 46 additions & 50 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$sms = new \Tecdiary\Sms\Sms($config);

$result = $sms->send(['+919090909090', '009190909090901'], 'This is test message for Log gateway.');
$result = $sms->send(['+919090909090', '009190909090901'], 'This is test message for Log gateway.')->response();
?><html>
<head>
<meta charset="UTF-8">
Expand All @@ -23,6 +23,6 @@
<pre/>

TECDIARY/SMS DEMO
<?php var_dump($result->status, $result->response); ?>
<?php var_dump($result); ?>
</body>
</html>
27 changes: 11 additions & 16 deletions src/Gateways/MVaayooGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@ class MVaayooGateway implements SmsGatewayInterface
public $logger;
public $response = '';

protected $gwvars = [];
protected $params = [];
protected $request = '';
protected $status = false;
protected $url = 'http://api.mVaayoo.com/mvaayooapi/MessageCompose?';

public function __construct($config, $logger)
{
$this->config = $config;
$this->logger = $logger;
$this->gwvars['receipientno'] = '';
$this->gwvars['msgtxt'] = '';
$this->gwvars['senderID'] = $this->config[$this->config['gateway']]['senderID'];
$this->gwvars['user'] = $this->config[$this->config['gateway']]['user'];
$this->gwvars['msgtype'] = 0;
$this->gwvars['state'] = 4;
$this->params['receipientno'] = '';
$this->params['msgtxt'] = '';
$this->params['senderID'] = $this->config[$this->config['gateway']]['senderID'];
$this->params['user'] = $this->config[$this->config['gateway']]['user'];
$this->params['msgtype'] = 0;
$this->params['state'] = 4;
}

public function getUrl()
{
foreach ($this->gwvars as $key => $val) {
foreach ($this->params as $key => $val) {
$this->request.= $key."=".urlencode($val);
$this->request.= "&";
}
Expand All @@ -37,8 +36,8 @@ public function getUrl()

public function sendSms($mobile, $message)
{
$this->gwvars['receipientno'] = $mobile;
$this->gwvars['msgtxt'] = $message;
$this->params['receipientno'] = $mobile;
$this->params['msgtxt'] = $message;
$client = new \GuzzleHttp\Client();
$this->response = $client->get($this->getUrl())->getBody()->getContents();
$this->logger->info('MVaayoo Response: '.$this->response);
Expand All @@ -47,10 +46,6 @@ public function sendSms($mobile, $message)

public function response()
{
$status = explode(',', $this->response);
if (trim($status[0]) == 'Status=0') {
$this->status = true;
}
return ['status' => $this->status, 'response' => $this->response];
return $this->response;
}
}
4 changes: 2 additions & 2 deletions src/Gateways/NexmoGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function getUrl()
return $this->url;
}

public function sendSms($mobiles, $message)
public function sendSms($mobile, $message)
{
$mobiles = explode(',', $mobiles);
$mobiles = explode(',', $mobile);
$this->composeBulkMobile($mobiles, $message);
return $this;
}
Expand Down
8 changes: 7 additions & 1 deletion src/Sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Sms
{
public $logger;
public $gateway;
public $status = false;

public function __construct($config)
{
Expand All @@ -19,7 +20,7 @@ public function send($phone_numbers, $message)
if ($phone_numbers = $this->composeBulkNumbers($phone_numbers)) {
return $this->gateway->sendSms($phone_numbers, $message);
}
return (object) ['status' => false, 'response' => 'The provided phone number(s) were not valid.'];
return $this;
}

public function composeBulkNumbers($phone_numbers)
Expand All @@ -44,4 +45,9 @@ public function composeBulkNumbers($phone_numbers)
$numbers = implode(',', $new_phone_numbers);
return $numbers;
}

public function response()
{
return $this->status;
}
}

0 comments on commit f210a7d

Please sign in to comment.