Skip to content

Commit

Permalink
Updated Query Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rtraselbd authored Jan 11, 2024
1 parent 6137888 commit 3aa4fc3
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/Provider/Ssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,49 @@ public function __construct(Sender $sender)
*/
public function sendRequest(): array
{
$mobile = $this->senderObject->getMobile();
$mobile = $this->formatNumber($this->senderObject->getMobile());
$config = $this->senderObject->getConfig();

$apiToken = $config['api_token'];
$sid = $config['sid'];
$csms_id = $config['csms_id'];

$data = [
'number' => $mobile,
'message' => $this->senderObject->getMessage()
'api_token' => $apiToken,
'sid' => $sid,
'msisdn' => $mobile,
'sms' => $this->senderObject->getMessage(),
'csms_id' => $csms_id
];

$message = $this->senderObject->getMessage();
$url = "https://smsplus.sslwireless.com/api/v3/send-sms?api_token=$apiToken&sid=$sid&sms=$message&msisdn=$mobile&csms_id=$csms_id";
$url = "https://smsplus.sslwireless.com/api/v3/send-sms";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$smsResult = curl_exec($ch);
if ($smsResult == false) {
$smsResult = curl_error($ch);
}
curl_close($ch);
return $this->generateReport($smsResult, $data);
}

/**
* For mobile number
* @param $mobile
* @return string
*/
private function formatNumber($mobile): string
{
if (mb_substr($mobile, 0, 2) == '01') {
$number = $mobile;
} elseif (mb_substr($mobile, 0, 2) == '88') {
$number = str_replace('88', '', $mobile);
} elseif (mb_substr($mobile, 0, 3) == '+88') {
$number = str_replace('+88', '', $mobile);
}
return '88' . $number;
}

/**
Expand All @@ -71,7 +90,6 @@ public function errorException()

if (empty($this->senderObject->getMessage()))
throw new XenonException('Message should not be empty');

}

/**
Expand All @@ -86,8 +104,8 @@ public function generateReport($result, $data): array
'response' => $result,
'provider' => self::class,
'send_time' => date('Y-m-d H:i:s'),
'mobile' => $data['number'],
'message' => $data['message']
'mobile' => $data['msisdn'],
'message' => $data['sms']
];
}
}
}

0 comments on commit 3aa4fc3

Please sign in to comment.