NetGSM Nedir?
NetGSM, Türkiye'nin en büyük toplu SMS servis sağlayıcısıdır. Pazarlama SMS'leri, OTP doğrulama kodları ve otomatik hatırlatma mesajları göndermek için kullanılır.
1. Tekli SMS Gönderimi
function send_sms($phone, $message) {
$usercode = '850XXXXXXX';
$password = 'API_SIFRE';
$msgheader = 'EKA SUNUCU';
$url = 'https://api.netgsm.com.tr/sms/send/get?'
. http_build_query([
'usercode' => $usercode,
'password' => $password,
'gsmno' => $phone,
'message' => $message,
'msgheader' => $msgheader,
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
2. OTP Doğrulama Kodu Gönderme
function send_otp($phone) {
$code = rand(100000, 999999);
$message = 'Dogrulama kodunuz: ' . $code
. ' Bu kodu kimseyle paylasmayin.';
send_sms($phone, $message);
$_SESSION['otp_code'] = $code;
$_SESSION['otp_expires'] = time() + 180;
return $code;
}