In this example we will be seeing how we can create an application that helps us send multiple messages through the sc_send_sms macro.
Creating a Control application
1 – We create an application of type Control.
2 – Once the application is created we must create 10 fields with the following types of data:
3 – Then we configure the following fields in this way:
- sms_group
- sms_gateway
- sms_date_time
- sms_binary
- sms_send_type
4 – After having configured the fields according to the images, we proceed to create the following methods:
5 – Within the m_sms_clickatell method we place the following:
$var_config = array(
'message' => [
'to' => {loc_numbers},
'from' => {loc_from_number},
'binary' => ({sms_binary}==1 ? true : false),
//clientMessageId' => ''
'scheduledDeliveryTime' => {sms_date_time}, // yyyy-MM-ddTHH:mm:ss-0300 -- 2018-01-01T10:01:10+0300
'validityPeriod' => {sms_periody}, //day
'charset' => {sms_charset}, //ASCII, UCS2-BE, UTF-8, Windows-1252
'message' => {loc_message},
],
'settings' => [
'gateway' => $p_gateway,
'auth_token' => {loc_token},
]
);
if(empty({sms_date_time}) || {sm_date_time}==""){
unset($var_config['message']['scheduledDeliveryTime']);
}
$return = sc_send_sms($var_config);
$msg_body = '<table class="table table-bordered table-striped">
<tr>
<td>MessageID</td>
<td>Acepted</td>
<td>TO</td>
<td>ErrorCode</td>
<td>Error</td>
<td>Error Message</td>
</tr>';
foreach($return as $key => $values){
$values['accepted'] = ($values['accepted'] == 1 ? 'Success' : $values['accepted']);
$msg_body .= "<tr>
<td>".$values['apiMessageId']."</td>
<td>".$values['accepted']."</td>
<td>".substr($values['to'],0,-3).'xxx'."</td>
<td>".$values['errorCode']."</td>
<td>".$values['error']."</td>
<td>".$values['errorDescription']."</td>
</tr>";
}
$msg_body .='</table>';
return $msg_body;
6 – In the m_sms_plivo method:
$var_config = array(
'message' => [
'to' => $loc_numbers,
'from' => $loc_from_number,
'message' => $loc_message,
'ValidityPeriod' => {sms_periody}, //seconds
'ProvideFeedback' => false, //feedback message API - true
],
'settings' => [
'gateway' => $p_gateway,
'auth_id' => $loc_sid,
'auth_token' => $loc_token,
]
);
/*
if(empty({sms_date_time}) || {sm_date_time}==""){
unset($var_config['message']['scheduledDeliveryTime']);
}
*/
$return = sc_send_sms($var_config);
$msg_body = '<table class="table table-bordered table-striped">
<tr>
<td>Message Response</td>
</tr>';
$msg_body .= "
<tr>
<td>".$return."</td>
</tr>";
$msg_body .='</table>';
return $msg_body;
7 – In the m_sms_twilio method:
$var_config = array(
'message' => [
'to' => $loc_numbers,
'from' => $loc_from_number,
//"mediaUrl" => "https://www.scriptcase.com.br/docs/pt_br/v9/assets/images/scriptcase-logo.svg",
'message' => $loc_message,
'ValidityPeriod' => {sms_periody}, //seconds
'ProvideFeedback' => false, //feedback message API - true
//'MessagingServiceSid' => '' //34 char unique from twilio service
'StatusCallback' => 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"],
//"MessagingServiceSid" => "",
],
'settings' => [
'gateway' => $p_gateway,
'auth_id' => $loc_sid,
'auth_token' => $loc_token,
]
);
/*
if(empty({sms_date_time}) || {sm_date_time}==""){
unset($var_config['message']['scheduledDeliveryTime']);
}
*/
$return = sc_send_sms($var_config);
$msg_body = '<table class="table table-bordered table-striped">
<tr>
<td>Message Response</td>
</tr>';
$msg_body .= "
<tr>
<td>".$return."</td>
</tr>";
$msg_body .='</table>';
return $msg_body;
8 – After creating these methods, we proceed to include a library that will help us complement what is necessary for the application:
9 – Then in the onScriptInit event we call the library as follows:
10 – Then inside the onLoad event:
?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script>
$(document).ready(function(){
$("#id_sc_field_sms_date_time").attr("placeholder", "dd/mm/aaaa hh:mm:ss");
$("#id_sc_field_sms_date_time").val("");
$("#sub_form_t").css("background-color","green");
$("#sub_form_t").css("color","white");
});
</script>
<?php
if({sms_send_type}==1){
sc_field_disabled("sms_unique_to");
sc_field_disabled("sms_group=false");
}else{
sc_field_disabled("sms_unique_to=false");
sc_field_disabled("sms_group");
}
11 – Inside the onValidateSuccess:
?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<script>
$(document).ready(function(){
$("#id_sc_field_sms_date_time").attr("placeholder", "dd/mm/aaaa hh:mm:ss");
$("#id_sc_field_sms_date_time").val("");
$("#sub_form_t").css("background-color","green");
$("#sub_form_t").css("color","white");
});
</script>
<?php
if({sms_send_type}==1){
sc_field_disabled("sms_unique_to");
sc_field_disabled("sms_group=false");
}else{
sc_field_disabled("sms_unique_to=false");
sc_field_disabled("sms_group");
}
12 – Finally we create an AJAX event of the sms_send_type field of type OnClick:
13 – We add the following:
if({sms_send_type}==1){
sc_field_disabled("sms_unique_to");
sc_field_disabled("sms_group=false");
}else{
sc_field_disabled("sms_unique_to=false");
sc_field_disabled("sms_group");
}
14 – Save the changes and run the application
Comment this post