I have an SMS app I want to set a time interval when the user sends SMS on a number then he needs to wait for 1 hour or any time interval which will declare in script how to do it?
<?php //FILE: sms_api.php
function sendSMS($number, $message) {
$url = "example"; // Set your frontlinesms or frontlinecloud webconnection url here
$secret = "secret"; // Set the secret here
$request = array(
'secret' => $secret,
'message' => $message,
'recipients' => array(array(
'type' => 'mobile',
'value' => $number
))
);
$req = json_encode($request);
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $req );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
curl_close($ch);
return split(',',$result);
}
?>
<?php //FILE: index.php
include 'sms_api.php';
$number = '+123456789';
$text = 'Hi There, how are you?';
$sms_api_result = sendSMS($number, $text);
// Check if SMS was sent. The $sms_api_result boolean indicates whether the API call was successful.
// You can replace the code below with custom handling logic
if ($sms_api_result[0] == 'OK') {
// Ok, SMS received by the API
echo 'The SMS was sent.';
}
else {
// Failure, SMS was not sent
// In this example we display the response to identify the error
print_r($sms_api_result);
}
?>
You can store the records in a database table. And Check for the mobile number at the time of sending sms. If he has sent sms in last hour you redirect him to a premium page or somewhere else. sleep will not work sleep will just increase the time it will take for your website to load.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.