<?php
function Send_SMS( $to, $text ) {
#example $to=”0812123456789,0852123456789,0819123456789″;
$pecah = explode( “,”, $to );
$jumlah = count( $pecah );
$from = “”; //Sender ID or SMS Masking Name, if leave blank, it will use default from telco
$username = “username_anda”; //your eims username
$password = “pass_key_md5_anda”; //your eims password yang didapat dari http://www.cmd5.org/hash.aspx
$postUrl = “http://xxxx.xxx.xxx.xxx:xxxxxx/eims_post_sms.html”; # DO NOT CHANGE THIS
for ( $i = 0; $i < $jumlah; $i ++ ) {
if ( substr( $pecah[ $i ], 0, 2 ) == “62” || substr( $pecah[ $i ], 0, 3 ) == “+62” ) {
$pecah = $pecah;
} elseif ( substr( $pecah[ $i ], 0, 1 ) == “0” ) {
$pecah[ $i ][0] = “X”;
$pecah = str_replace( “X”, “62”, $pecah );
} else {
echo “Invalid mobile number format”;
}
$request = [
‘version’ => ‘2.0’,
‘username’ => $username,
‘password’ => $password,
‘key’ => ‘key_anda’, //key yang didapatkan dari https://tool.lu/timestamp/
‘task_num’ => ‘1’,
‘tasks’ => [
[
‘tid’ => 123456,
‘to’ => $to,
‘sms’ => $text
]
]
];
$data_string = json_encode( $request );
$ch = curl_init( $postUrl );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, “POST” );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Accept:application/json’
)
);
$response = curl_exec( $ch );
$httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
$responseBody = json_decode( $response );
if ( $httpCode == 200 ) {
return print_r((array)$responseBody);
}
curl_close( $ch );
}
}
$to = “6281210100055”;//masukkan nomor tujuan
$message = “ISI SMS”;//masukkan isi pesan
Send_SMS( $to, $message );
?>