codigo actual del servidor, con avances de joan
This commit is contained in:
66
app/Services/OTP/Fast2sms.php
Normal file
66
app/Services/OTP/Fast2sms.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Fast2sms implements SendSms {
|
||||
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
if (strpos($to, '+91') !== false) {
|
||||
$to = substr($to, 3);
|
||||
}
|
||||
|
||||
if (env("ROUTE") == 'dlt_manual') {
|
||||
$fields = array(
|
||||
"sender_id" => env("SENDER_ID"),
|
||||
"message" => $text,
|
||||
"template_id" => $template_id,
|
||||
"entity_id" => env("ENTITY_ID"),
|
||||
"language" => env("LANGUAGE"),
|
||||
"route" => env("ROUTE"),
|
||||
"numbers" => $to,
|
||||
);
|
||||
} else {
|
||||
$fields = array(
|
||||
"sender_id" => env("SENDER_ID"),
|
||||
"message" => $text,
|
||||
"language" => env("LANGUAGE"),
|
||||
"route" => env("ROUTE"),
|
||||
"numbers" => $to,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$auth_key = env('AUTH_KEY');
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://www.fast2sms.com/dev/bulkV2",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_SSL_VERIFYHOST => 0,
|
||||
CURLOPT_SSL_VERIFYPEER => 0,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => "POST",
|
||||
CURLOPT_POSTFIELDS => json_encode($fields),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
"authorization: $auth_key",
|
||||
"accept: */*",
|
||||
"cache-control: no-cache",
|
||||
"content-type: application/json"
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
16
app/Services/OTP/Mimo.php
Normal file
16
app/Services/OTP/Mimo.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
use App\Utility\MimoUtility;
|
||||
|
||||
class Mimo implements SendSms{
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$token = MimoUtility::getToken();
|
||||
|
||||
MimoUtility::sendMessage($text, $to, $token);
|
||||
MimoUtility::logout($token);
|
||||
}
|
||||
}
|
||||
28
app/Services/OTP/Mimsms.php
Normal file
28
app/Services/OTP/Mimsms.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Mimsms implements SendSms{
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$url = env('MIM_BASE_URL') . "/smsapi";
|
||||
$data = [
|
||||
"api_key" => env('MIM_API_KEY'),
|
||||
"type" => "text",
|
||||
"contacts" => $to,
|
||||
"senderid" => env('MIM_SENDER_ID'),
|
||||
"msg" => $text,
|
||||
];
|
||||
$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);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
28
app/Services/OTP/Msegat.php
Normal file
28
app/Services/OTP/Msegat.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Msegat implements SendSms {
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$url = "https://www.msegat.com/gw/sendsms.php";
|
||||
$data = [
|
||||
"apiKey" => env('MSEGAT_API_KEY'),
|
||||
"numbers" => $to,
|
||||
"userName" => env('MSEGAT_USERNAME'),
|
||||
"userSender" => env('MSEGAT_USER_SENDER'),
|
||||
"msg" => $text
|
||||
];
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
40
app/Services/OTP/Nexmo.php
Normal file
40
app/Services/OTP/Nexmo.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Nexmo implements SendSms {
|
||||
public function send($to, $from, $text, $template_id) {
|
||||
$api_key = env("NEXMO_KEY"); //put ssl provided api_token here
|
||||
$api_secret = env("NEXMO_SECRET"); // put ssl provided sid here
|
||||
|
||||
$params = [
|
||||
"api_key" => $api_key,
|
||||
"api_secret" => $api_secret,
|
||||
"from" => env("NEXMO_SENDER_ID"),
|
||||
"text" => $text,
|
||||
"to" => $to
|
||||
];
|
||||
|
||||
$url = "https://rest.nexmo.com/sms/json";
|
||||
$params = json_encode($params);
|
||||
|
||||
$ch = curl_init(); // Initialize cURL
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($params),
|
||||
'accept:application/json'
|
||||
));
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
29
app/Services/OTP/Sparrow.php
Normal file
29
app/Services/OTP/Sparrow.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Sparrow implements SendSms {
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$url = "http://api.sparrowsms.com/v2/sms/";
|
||||
|
||||
$args = http_build_query(array(
|
||||
"token" => env('SPARROW_TOKEN'),
|
||||
"from" => env('MESSGAE_FROM'),
|
||||
"to" => $to,
|
||||
"text" => $text
|
||||
));
|
||||
# Make the call using API.
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
// Response
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
43
app/Services/OTP/SslWireless.php
Normal file
43
app/Services/OTP/SslWireless.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class SslWireless implements SendSms {
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$token = env("SSL_SMS_API_TOKEN"); //put ssl provided api_token here
|
||||
$sid = env("SSL_SMS_SID"); // put ssl provided sid here
|
||||
|
||||
$params = [
|
||||
"api_token" => $token,
|
||||
"sid" => $sid,
|
||||
"msisdn" => $to,
|
||||
"sms" => $text,
|
||||
"csms_id" => date('dmYhhmi') . rand(10000, 99999)
|
||||
];
|
||||
|
||||
$url = env("SSL_SMS_URL");
|
||||
$params = json_encode($params);
|
||||
|
||||
$ch = curl_init(); // Initialize cURL
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($params),
|
||||
'accept:application/json'
|
||||
));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
29
app/Services/OTP/Twillo.php
Normal file
29
app/Services/OTP/Twillo.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
use Twilio\Rest\Client;
|
||||
|
||||
class Twillo implements SendSms
|
||||
{
|
||||
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
$sid = env("TWILIO_SID"); // Your Account SID from www.twilio.com/console
|
||||
$token = env("TWILIO_AUTH_TOKEN"); // Your Auth Token from www.twilio.com/console
|
||||
$type = env("TWILLO_TYPE"); // sms type
|
||||
|
||||
$client = new Client($sid, $token);
|
||||
try {
|
||||
$client->messages->create(
|
||||
($type == 1) ? $to : "whatsapp:" . $to, // Text this number
|
||||
array(
|
||||
'from' => ($type == 1) ? env('VALID_TWILLO_NUMBER') : "whatsapp:" . env('VALID_TWILLO_NUMBER'), // From a valid Twilio number
|
||||
'body' => $text
|
||||
)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
62
app/Services/OTP/Zender.php
Normal file
62
app/Services/OTP/Zender.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\OTP;
|
||||
|
||||
use App\Contracts\SendSms;
|
||||
|
||||
class Zender implements SendSms {
|
||||
public function send($to, $from, $text, $template_id)
|
||||
{
|
||||
if (empty(env('ZENDER_SERVICE')) || env('ZENDER_SERVICE') < 2) {
|
||||
if (!empty(env('ZENDER_DEVICE'))) {
|
||||
$mode = "devices";
|
||||
} else {
|
||||
$mode = "credits";
|
||||
}
|
||||
|
||||
if ($mode == "devices") {
|
||||
$params = [
|
||||
"secret" => env('ZENDER_APIKEY'),
|
||||
"mode" => "devices",
|
||||
"device" => env('ZENDER_DEVICE'),
|
||||
"phone" => $to,
|
||||
"message" => $text,
|
||||
"sim" => env('ZENDER_SIM') < 2 ? 1 : 2
|
||||
];
|
||||
} else {
|
||||
$params = [
|
||||
"secret" => env('ZENDER_APIKEY'),
|
||||
"mode" => "credits",
|
||||
"gateway" => env('ZENDER_GATEWAY'),
|
||||
"phone" => $to,
|
||||
"message" => $text
|
||||
];
|
||||
}
|
||||
|
||||
$apiurl = env('ZENDER_SITEURL') . "/api/send/sms";
|
||||
} else {
|
||||
$params = [
|
||||
"secret" => env('ZENDER_APIKEY'),
|
||||
"account" => env('ZENDER_WHATSAPP'),
|
||||
"type" => "text",
|
||||
"recipient" => $to,
|
||||
"message" => $text
|
||||
];
|
||||
|
||||
$apiurl = env('ZENDER_SITEURL') . "/api/send/whatsapp";
|
||||
}
|
||||
|
||||
$args = http_build_query($params);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $apiurl);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
// Response
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user