|
//------------------
send SMS ----------------------------------------
//set
value of property; "ToNumber" is the recipient's number;
"ToMessage" is the SMS to be send to the recipient
SMSAPIJava.setProperty("ToNumber",
"0163311600");
SMSAPIJava.setProperty("ToMessage",
"Hello from JAVA. Test DSR 6");
//call
API to send out SMS, the return value of the API call is assigned to
"SMSAPIReturnValue"
SMSAPIReturnValue
= SMSAPIJava.invoke("SendSMS");
//since
the return value of "SendSMS" is a boolean, so extract the
return value as a boolean and assign to "bSMS"
bSMS
= SMSAPIReturnValue.getBoolean();
if
(bSMS)
{
System.out.println("Messange
sent!");
//try
3 times
for
(int
i=1; i<=3; i++)
{
//call
API to get delivery status report, the return value of the API call
is assigned to "SMSAPIReturnValue"
SMSAPIReturnValue
= SMSAPIJava.invoke("GetDeliveryReport");
//since
the return value of "GetDeliveryStatusReport" is a boolean,
so extract the return value as a boolean and assign to "bSMS"
bSMS
= SMSAPIReturnValue.getBoolean();
if
(bSMS)
{
//when
"GetDeluveryStatusReport = True", then get value of
properties
int
DRStatus = SMSAPIJava.getPropertyAsInt("DRStatus");
String
DRMNRecipient = SMSAPIJava.getPropertyAsString("DRMNRecipient");
String
DRMsgRef = SMSAPIJava.getPropertyAsString("DRMsgRef");
String
DRFDate = SMSAPIJava.getPropertyAsString("DRFDate");
String
DRFTime = SMSAPIJava.getPropertyAsString("DRFTime");
String
DRRDate = SMSAPIJava.getPropertyAsString("DRRDate");
String
DRRTime = SMSAPIJava.getPropertyAsString("DRRTime");
if
(DRStatus == 1)
{
//System.out.println("The
status of your outgoing SMS with reference number, " + DRMsgRef
+ ", is " + DRStatus + ".");
System.out.println("The
status of your outgoing SMS with reference number, "
+ DRMsgRef + ", is delivered.");
System.out.println("Your
outgoing SMS was received by the SMS Centre on "
+ DRRDate + ", at "
+ DRRTime + ", and was successfully
delivered to " + DRMNRecipient + ",
on " + DRFDate + ",
at " + DRFTime + ".");
}
else
if
(DRStatus == 0)
{
//System.out.println("The
status of your outgoing SMS with reference number, " + DRMsgRef
+ ", is " + DRStatus + ".");
System.out.println("The
status of your outgoing SMS with reference number, "
+ DRMsgRef + ", is not
delivered.");
System.out.println("Your
outgoing SMS was received by the SMS Centre on "
+ DRRDate + ", at "
+ DRRTime + ", and was NOT
successfully delivered to " +
DRMNRecipient + ".");
}
else
if
(DRStatus == 2)
{
//System.out.println("The
status of your outgoing SMS with reference number, " + DRMsgRef
+ ", is " + DRStatus + ".");
System.out.println("The
status of your outgoing SMS with reference number, "
+ DRMsgRef + ", is unknown.");
System.out.println("Your
outgoing SMS was received by the SMS Centre on "
+ DRRDate + ", at "
+ DRRTime + ", and NO status is
available.");
}
break;
}
else
{
System.out.println("No
delivery status report available!");
}
}
}
else
{
System.out.println("Messange
NOT sent!");
}
//------------------
end: send SMS ----------------------------------------
|