Answers for "send OTP php"

PHP
0

send OTP php

<?php
	$otp = rand(1000,9999);
	$phone = "+910123456789"; // target number; includes ISD
	$api_key = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'; // API Key
	$req = "https://2factor.in/API/V1/".$api_key."/SMS/".$phone."/".$otp;

	$sms = file_get_contents($req);
	$sms_status = json_decode($sms, true);
	if($sms_status['Status'] !== 'Success') {
		$err['error'] = 'Could not send OTP to '.$phone;
	}
?>
Posted by: Guest on July-28-2021

Browse Popular Code Answers by Language