sms finish

This commit is contained in:
merdan 2022-02-02 12:37:46 +05:00
parent c10ed056e8
commit a1a0179cb8
5 changed files with 28 additions and 46 deletions

View File

@ -18,51 +18,16 @@ class SmsController extends Controller
public function index(SmppServiceInterface $smpp) {
// $smpp->sendOne(99363432211, 'Hi, this SMS was send via SMPP protocol');
$tx=new SMPPV2('217.174.228.218', 5019); // make sure the port is integer
$tx->debug=true;
// $tx->debug=true;
$tx->bindTransmitter("birja","Birj@1");
dump('bind transmitter');
// dump('bind transmitter');
$result = $tx->sendSMS("0773",'99363432211','message');
dump('send sms attempt');
echo $tx->getStatusMessage($result);
// dump('send sms attempt');
// echo $tx->getStatusMessage($result);
$tx->close();
unset($tx);
return 'success';
// return $this->setupSMPP();
return $result;
}
private function setupSMPP(){
$transport = new SocketTransport(['217.174.228.218'], 5019);
try {
$transport->setRecvTimeout(10000);
SmppClient::$sms_null_terminate_octetstrings = false;
$smpp = new SmppClient($transport);
$smpp->debug = true;
$transport->debug = true;
$transport->open();
$smpp->bindTransmitter('birja', 'Birj@1');
$message = 'H€llo world';
$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress('0773');
$to = new SmppAddress('99363432211');
// Send
$response = $smpp->sendSMS($from,$to,$message,null,SMPP::DATA_CODING_ISO8859_1);
// Close connection
$smpp->close();
dd($response);
}
// Skipping unavailable
catch (SmppException $ex) {
$transport->close();
throw $ex;
}
}
}

View File

@ -15,3 +15,6 @@ attributes:
email:
label: Email address
phone_verified:
label: Phone verified

View File

@ -232,6 +232,7 @@ class Plugin extends PluginBase
VerifyAction::class
],
'conditions' => [
\RainLab\User\NotifyRules\UserAttributeCondition::class
],
'groups' => [
'payment' => [

View File

@ -36,7 +36,7 @@ class SendSMSAction extends ActionBase
'send_to_mode' => 'required',
'send_to_custom' => 'required_if:send_to_mode,custom',
// 'send_to_admin' => 'required_if:send_to_mode,admin',
'message' => 'required'
'message' => 'required|string|max:160'
];
}
/**
@ -65,9 +65,9 @@ class SendSMSAction extends ActionBase
public function getTitle()
{
if ($this->isAdminMode()) {
return 'Send sms to administrators';
}
// if ($this->isAdminMode()) {
// return 'Send sms to administrators';
// }
return 'Send sms to customers';
}
@ -85,6 +85,8 @@ class SendSMSAction extends ActionBase
{
if($this->host->send_to_mode == 'user' && $params['user']){
if(!$params['user']['phone_verified'])
return;
$to = $params['user']['username'];
}else{

View File

@ -5,16 +5,27 @@ namespace TPS\Birzha\Classes;
use Exception;
use Illuminate\Support\Facades\Log;
use October\Rain\Support\Facades\Http;
use TPS\Birzha\Classes\SMPP;
class SMS
{
public static function send($to, $content){
$url = urlencode(env('SMS_API')."$to/{$content}");
try {
$response = Http::get($url);
$tx = new SMPP(env('SMPP_IP','217.174.228.218'), env('SMPP_PORT',5019)); // make sure the port is integer
$tx->bindTransmitter(env('SMPP_USER',"birja"),env('SMPP_PASS',"Birj@1"));
$result = $tx->sendSMS(env('SMPP_SENDER',"0773"),$to,$content);
$tx->close();
unset($tx);
return $result;
}
catch (Exception $exception){
Log::error($exception);
return false;
}
}
}