Initial commit
This commit is contained in:
33
app/Libs/Ntfysender.php
Normal file
33
app/Libs/Ntfysender.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libs;
|
||||
|
||||
use Config;
|
||||
use Log;
|
||||
use App;
|
||||
class Ntfysender {
|
||||
|
||||
function sendNtfy($data){
|
||||
$url = 'https://ntfy.sh/airtimeSalesPortal';
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
64
app/Libs/Smsgateway.php
Executable file
64
app/Libs/Smsgateway.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libs;
|
||||
|
||||
use Config;
|
||||
use Log;
|
||||
use App;
|
||||
class Smsgateway {
|
||||
|
||||
function sendSms($msisdn, $message){
|
||||
$url ="http://10.199.0.10/ucm_api/index.php";
|
||||
$data = array (
|
||||
'reference' => uniqid('_airtime'),
|
||||
'message_type' => "1",
|
||||
'message' => $message,
|
||||
'user_id' => "288",
|
||||
'app_id' => "600118",
|
||||
'org_id' => "82",
|
||||
'src_address' => "349",
|
||||
'dst_address' => $msisdn,
|
||||
'service_id' => "",
|
||||
'operation' => "send",
|
||||
'timestamp' => preg_replace('/\D/', '', date("YYYYmmddHHiiss")),
|
||||
'auth_key' => md5(600118 . date("YYYYmmddHHiiss") . "!QAZ2wsx*")
|
||||
);
|
||||
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
$ucm_response = curl_exec($curl);
|
||||
|
||||
@file_put_contents("/var/www/html/malawi/airtime_sales_portal/public/logs/" . date("Y_m_d_") . "sms_responses.txt", $ucm_response . PHP_EOL, FILE_APPEND);
|
||||
return $ucm_response;
|
||||
}
|
||||
function sendSmsNew($msisdn, $message){
|
||||
$url = "http://10.199.0.10:8989/api/messaging/sendsms";
|
||||
$token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI4MiIsIm9pZCI6ODIsInVpZCI6IjRkNTUzZTZhLTBmYzAtNDJjNy05MWMyLTk5ZmUzNDliNWFmYSIsImFwaWQiOjkxLCJpYXQiOjE2NDg0NjQxOTQsImV4cCI6MTk4ODQ2NDE5NH0.Nndr6MshNvpiYoqv3aLI_sw9kSZP1dUUBa-aWQ1y0iHlkLe0DhLZymUl430IBVOOGI--Rl_ur1JEAJ-8BRhS2w";
|
||||
$data = array (
|
||||
'from' => "349",
|
||||
'to' => $msisdn,
|
||||
'message' => $message,
|
||||
'refId' => uniqid('_airtime')
|
||||
);
|
||||
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
"Authorization: Bearer $token",
|
||||
"Content-type: application/json"
|
||||
));
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
$ucm_response = curl_exec($curl);
|
||||
|
||||
@file_put_contents("/var/www/html/malawi/airtime_sales_portal/public/logs/" . date("Y_m_d_") . "sms_responses.txt", $ucm_response . PHP_EOL, FILE_APPEND);
|
||||
return $ucm_response;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user