<?php
namespace App\Helpers;
use Log;
class NotifWa {
public static function send($no_hp, $message) {
//check $no_hp have +62
if (strpos($no_hp, '+62') !== 0) {
//if leading zero remove it
$no_hp = ltrim($no_hp, '0');
$no_hp = '+62' . $no_hp;
}
//check if length less than 10
if (strlen($no_hp) < 10) {
return false;
}
$key=env("WOOWA_KEY"); //this is demo key please change with your own key
$url='https://notifapi.com/async_send_message';
$data = array(
"phone_no" => $no_hp,
"key" => $key,
"message" => $message,
"skip_link" => True, // This optional for skip snapshot of link in message
"pendingTime" => 3 // This optional for delay before send message
);
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$res=curl_exec($ch);
curl_close($ch);
return $res;
}
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]