mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-13 03:31:06 +03:30
Forgot Password BackEnd
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Packages\SMSSender;
|
||||
|
||||
class SMSSender
|
||||
{
|
||||
private $userName = null;
|
||||
private $password = null;
|
||||
private $webService = null;
|
||||
private $fromNumber = null;
|
||||
private $messageFee = 15;
|
||||
private $type = 'Other';
|
||||
private static $panel = null;
|
||||
private $pattern = [
|
||||
'121' => 'کد فعال سازی: %activate-code%',
|
||||
];
|
||||
|
||||
private function __construct() { }
|
||||
|
||||
public static function instance() {
|
||||
if (static::$panel === null) {
|
||||
static::$panel = new static();
|
||||
}
|
||||
return static::$panel;
|
||||
}
|
||||
|
||||
public function setUserName ($userName)
|
||||
{
|
||||
$this->userName = $userName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPassword ($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWebService ($webService)
|
||||
{
|
||||
$this->webService = $webService;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserName ()
|
||||
{
|
||||
return ($this->userName) ? $this->userName : env('SMS_USERNAME', '');
|
||||
}
|
||||
|
||||
public function getPassword ()
|
||||
{
|
||||
return ($this->password) ? $this->password : env('SMS_PASSWORD', '');
|
||||
}
|
||||
|
||||
public function getFromNumber ()
|
||||
{
|
||||
return ($this->fromNumber) ? $this->fromNumber : env('SMS_FROM_NUMBER', '');
|
||||
}
|
||||
|
||||
public function getWebService ()
|
||||
{
|
||||
return ($this->webService) ? $this->webService : env('SMS_WEBSERVICE', '');
|
||||
}
|
||||
|
||||
public function patternSend($cellNumber, $pattern_code, $input_data)
|
||||
{
|
||||
if (is_string($cellNumber)) {
|
||||
$cellNumber = [$cellNumber];
|
||||
}
|
||||
try {
|
||||
$user = $this->getUserName();
|
||||
$pass = $this->getPassword();
|
||||
$fromNum = $this->getFromNumber();
|
||||
|
||||
$client = new \SoapClient($this->getWebService());
|
||||
$client->sendPatternSms($fromNum, $cellNumber, $user, $pass, $pattern_code, $input_data);
|
||||
|
||||
} catch (\SoapFault $sf) {
|
||||
print $sf->faultcode . "\n";
|
||||
print $sf->faultstring . "\n";
|
||||
return ['code' => $sf->faultcode, 'message' => $sf->faultstring];
|
||||
}
|
||||
}
|
||||
|
||||
public function send($cellNumber, $messageContent)
|
||||
{
|
||||
if (is_string($cellNumber)) {
|
||||
$cellNumber = [$cellNumber];
|
||||
}
|
||||
ini_set("soap.wsdl_cache_enabled", "0");
|
||||
try {
|
||||
$user = $this->getUserName();
|
||||
$pass = $this->getPassword();
|
||||
$fromNum = $this->getFromNumber();
|
||||
//If you want to send in the future ==> $time = '2016-07-30' //$time = '2016-07-30 12:50:50'
|
||||
$client = new \SoapClient($this->getWebService());
|
||||
$client->SendSMS($fromNum, $cellNumber, $messageContent, $user, $pass, '', 'send');
|
||||
return true;
|
||||
} catch (\SoapFault $sf) {
|
||||
print $sf->faultcode . "\n";
|
||||
print $sf->faultstring . "\n";
|
||||
return ['code' => $sf->faultcode, 'message' => $sf->faultstring];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user