Mobitek System sells GSM Modem

SMS API for JAVA

 

Now, Java developers can use our SMS API to build Java applications that can send and receive SMS.

Our SMS API for Java is a simple API package that contains:-

  • SMS API Type COM-ActiveX
  • JACOB
  • JRE 1.6
  • Elipse

The SMS API for Java is free when you purchase GSM modem from us.

SMS API for JAVA developers. The following example gives you detailed instructions on how you can send a SMS messages from Java:-

//------------------ 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 ----------------------------------------

 

 

Guide for Software Developer and System Integrator

Contact us

Copyright Reserved

 

GSM Modem Malaysia, GPRS Modem Malaysia, 3G Modem Malaysia, SMS Gateway Malaysia, GSM Modem Indonesia, GPRS Modem Indonesia, 3G Modem Indonesia, SMS Gateway Indonesia, GSM Modem Philippines, GPRS Modem Philippines, 3G Modem Philippines, SMS Gateway Philippines, GSM Modem USA, GPRS Modem USA, 3G Modem USA, SMS Gateway USA