Using URL in Java to send sms ( Intelligent IP Monitoring )

hi all
i have created a IP monitoring where in case of faulty it will send sms based on the error that has been caused in they system, i used this code before but did not responded
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.Vector;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
  public void run() {
    try {
      while (go) {
        str = logs.getText();
        logs.setText(str + System.getProperty("line.separator") + name + " Start Pinging .... ");
        boolean reachable=false;
        try {
            InetAddress address = InetAddress.getByName(name);
            reachable =address.isReachable(3000);
            if (address.isReachable(3000) == false) {
                str = logs.getText();
                logs.setText(str + System.getProperty("line.separator") + name + " : Time Out ... ");
                for(int i = 0 ; i < phonenumbers.size() ; i++){
                    try {
                        URL u = new URL("https://myaccount.dialnow.com/clx/sendsms.php?username= xxxxxxx&#8203; &#8203;&" +
                                "password= xxxxxxx&#8203;&from= xxxxxxx&#8203;&to=" +
                                phonenumbers.get(i) + "&text="
                                + name + ":TimeOut...");
                        URLConnection uc = u.openConnection();
                    } catch (IOException ex) {
                        Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnknownHostException e){
            str = logs.getText();
            logs.setText(str + System.getProperty("line.separator") + name + " : Unable to Lookup ... ");
            for(int i = 0 ; i < phonenumbers.size() ; i++){
                try {
                    URL u = new URL("https://myaccount.dialnow.com/clx/sendsms.php?username= xxxxxxx&#8203; &#8203;&" +
                            "password= xxxxxxx&#8203;&from= xxxxxxx&#8203;&to=" +
                            phonenumbers.get(i) + "&text="
                            + name + ":Unable to Lookup...");
                    URLConnection uc = u.openConnection();
                } catch (IOException ex) {
                    Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException e){
            str = logs.getText();
            logs.setText(str + System.getProperty("line.separator") + name + " : Unable to Reach ... ");
            for(int i = 0 ; i < phonenumbers.size() ; i++){
                try {
                    URL u = new URL("https://myaccount.dialnow.com/clx/sendsms.php?username= xxxxxxx&#8203; &#8203;&" +
                            "password= xxxxxxx&#8203;&from= xxxxxxx&#8203;&to=" +
                            phonenumbers.get(i) + "&text="
                            + name + ":Unable to Reach...");
                    URLConnection uc = u.openConnection();
                } catch (IOException ex) {
                    Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        } catch(Exception e1){
            str = logs.getText();
            logs.setText(str + System.getProperty("line.separator") + name + " : Exception Error ... ");
            for(int i = 0 ; i < phonenumbers.size() ; i++){
                try {
                    URL u = new URL("https://myaccount.dialnow.com/clx/sendsms.php?username=xxxxxxx&#8203;&" +
                            "password= xxxxxxx&#8203;&from= xxxxxxx&#8203;&to=" +
                            phonenumbers.get(i) + "&text="
                            + name + ":Exception Error...");
                    URLConnection uc = u.openConnection();
                } catch (IOException ex) {
                    Logger.getLogger(menu.class.getName()).log(Level.SEVERE, null, ex);
        TimeUnit.SECONDS.sleep(10);
    } catch (InterruptedException e) {
      System.out.println(name + "Interrupted");
    System.out.println(name + " exiting.");
}the system dose not give error but it dose not send sms either i found out that it was cus of the url and the gateway that iw as using so i found a new gatway which is in malaysia ( thats where im implementing my system) and this is how the new source code looks like for the URL
  URL u = new URL("http://www.bulksms2u.com/websmsapi/ISendSMS.aspx?username=xxxxx" +
                             "&password=xxxxx&message" + name + ":Unable to Lookup..." + "&mobile="
                             + phonenumbers.get(i) + "&sender=IP-Admin&type=1");
                    URLConnection uc = u.openConnection();i have replaced it with the old one which it was
URL u = new URL("https://myaccount.dialnow.com/clx/sendsms.php?username= xxxxxxx&#8203; &#8203;&" +
                                "password= xxxxxxx&#8203;&from= xxxxxxx&#8203;&to=" +
                                phonenumbers.get(i) + "&text="
                                + name + ":TimeOut...");this new url works i have tried it using direct url into a explorer and the sms has been sent but this way it dose not work
dose any one have any clue what should i do to get respond for sending this sms?

soudshoja wrote:
i tried applying it directly into browser did not work, I thought you said it did work. The reason is that browser a lot of the time will apply URL encoding on things manually entered.
and about ( URL encode the parameter values before concatenating them into the URL. ) i dont get what u mean can you be specific?Check java.net.URLEncoder Only specific characters are allowed in a URL, other characters need to be encoded/escaped using a process called URL encoding

Similar Messages

  • Can we use MIDP 1.0 to send SMS from mobile phone to server

    hello,
    I want to develop MIDlet which send sms from mobile phone to server
    using midp 1.0
    and also if any one knows about the mobile phone which suppoet midp 1.0 (java enabled) then tell me
    thanks in advance
    s.j.koradiya

    hi,
    SMS API(WMA) is an optional package. It is not a MIDP1.0 or MIDP2.0 api's.
    There are phones which has WMA api with MIDP1.0 support .... Nokia 3650
    Seimens has some phone with their own api's to send sms.Check out seimens site for more info
    BTW, What do you mean buy sending SMS to Server????
    If you want to send message to server you can do it with Http.
    HTH
    phani

  • CANNOT send SMS messages with ADDRESS BOOK on POWERBOOK using iPHONE

    I cannot send SMS messages with my address book or dial phone numbers using my Powerbook via the iPHONE.
    Previously, with my Sony Ericson phone, I could do both. It's very useful, when you are at your laptop, to use your computer keyboard to send SMS text messages back and forth rather than using the clumsy small keys on a phone.
    Can someone help?
    Is there something I am missing?
    Message was edited by: Host

    You are not missing something here and no one here can help you. This is not an included Bluetooth profile with the iPhone at the present time anyway.
    If you purchased your iPhone within the last 14 days, you can return it for credit less a 10% restocking fee and if not, here is Apple's feedback link for the iPhone.
    http://www.apple.com/feedback/iphone.html

  • Send SMS from Android tablet via Nokia phone using...

    Hi
    On my Windows PC I frequently use Nokia PC Suite to send SMS messages by linking to my old Nokia 6230i using bluetooth. So much quicker to type using a keyboard.
    Having now bought an Android tablet I've been looking for an app that would let me do the same, again using bluetooth to connect to the Nokia 6230i to send the SMS. But I've not found one.
    I've search this forum for someone looking for a similar solution and also searched the google play, again without luck.
    If anyone knows a solution then I love to hear about it.
    Alan
    PS Had to register again on this forum, probably because it's been a long time since I visited

    Hi, Alan_UK2. The PC suite can only be downloaded only your PC. Since this is a third-party OS, you may check if they have an available application for your tablet that has the feature you are looking for. 

  • Send sms to mobile over internet

    I want to send sms over Internet. i m unable to make this module..
    from where i can get sms server and gateway in java .
    where i can find this complete module.

    Sree,
    If you directly ask for any example source, nobody would probably help you out. Show the effort and tell when you getting stuck and then people would be really helpful.
    To send SMS you need to use SMPP protocol. There are many open source libraries and one of them is logica . Using this library you can send sms to any real SMSC or simulator.

  • Unable to send SMS

    I've lost the capability to send SMS messages.  It's always switching to MMS mode even if I've set it up to always send text-only message as SMS.  The SMS settings in Text Messaging -> Options is also gone.  I used to be able to send SMS.  I've done soft and hard reset but the problem persists.  Please help.  How can I get the SMS settings back in Text Messaging -> Options screen?
    Thanks.

    Hey redj28,
    Welcome to the BlackBerry Support Community Forums.
    Thanks for the question.
    I would first suggest removing the battery and placing it back in.  Then try to send an SMS message.  When was the last time you were able to send an SMS message?  Did you do any changes to your account?
    I look forward to your reply.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • Can't send SMS from iPhone 4, iOS 5.0.1

    Hello! I have an iPhone 4 with iOS 5.0.1 simfree. I can recieve sms but I can't send one. It seems like there are issues with imessage, 'cause it says "waiting for activation" and doesn't offer me use my phone number to send sms via, but only my e-mail. I suppose it's a bug of ios version, right? If not, then what can I do? How can I make sms sending fuction working? All the options like "send sms", "send mms" are on. I have tried to reboot the iOS and restore it - doesn't help.

    I suppose it's a bug of ios version, right?
    Wrong.
    If not, then what can I do?
    To start, you could post some useful info such as your carrier and location.  Do you have SMS/MMS enabled on your plan with your carrier?  Did you contact them to check?

  • How can I use HyperLink In Java Applet..

    I am new In Java Programming And i Want to create a Hyperlink OR URL in java Applet, How can be It possible?

    well u can use a hyperlink as a url by using url from java.net.url class
    define ur url .... u can check the API fo r that
    and by using wht u mean .. u want to browse in applet with that url or wht
    if u want to do browing in applet than u will also have to do parsing of all HTML tags
    hope it will help u

  • Sending sms from server

    Well i have to send short message from webserver to any client.But not from client to client.Like any products inforamtions to clients.Because i can't find api in any webserver to send sms to client.While from client I have found api in sl45i to send to any smsc server.But not in webserver.
    I i will make this possible.
    Thanks
    Jawwad Ahmed

    I don't quite understand what you are trying to do but so far, here is what I have understood.
    1. You want to send SMS from Webserver to your mobile phone
    2. Want J2ME Emulator to process SMS.
    <1> Sending SMS from webserver is quite easy. You have several options:(a) connect a mobile phone to your server and 'talk' to the phone using Gnokii or GSMLib to send SMS. The mobile phone will take care of communicating with SMSC of your provider (b) get in touch with your provider and ask if you can connect to their SMSC directly. Some allow you to connect to their SMSC via a modem connection (c) look for public SMSC's, which are scarce.
    <2> Unfortunately, MIDP 1.0 does not allow you to retrieve SMS from the phone... nor does the Siemens SDK, AFAIK. You cannot process SMS using the Emulator as well. You need a real device to test your application.

  • Can't send SMS but can receive

    I charged my phone while on wifi and I guess it synced with iCloud. Now I can send and receive iMessages and receive SMS but can't send SMS please help. I am using net10. Please help.

    Sending SMS is a carrier feature.  Contact your carrier

  • Send SMS with ElitePad question

    Hi,
    We are running a communication software on the ElitePad, on other tablets we use a USB dongle to send SMS using its COM port.
    The mobile broadband does not show up as a COM port on the elitePad and we can not use it to send SMS, does anyone know of a workaround to expose a COMport?
    Our software uses AT commands to send SMS, it would be impractical for us to rewrite our software at this point. We would also like to avoid using a USB modem connected to the ElitePad.
    Thanks

    Hello RTdev,
    The ElitePad is a Business model.  Your issue would be best answered on the HP Enterprise Business Community Forum
    Good luck!
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • How Can I send SMS to a Mobile Phone within Oracle

    How Can I send SMS to a Mobile Phone within Oracle

    It depends on how you are planning to use this feature.
    You can set up a mobile using special software in order to interface to it programatically - you can then, via this software interface, use this mobile to send SMS's.
    Some service providers support an e-mail interface. Where you send the SMS as a the e-mail content and the mobile number as the recipient's address, or as the subject of the e-mail. However, many service providers have long since stopped providing this type of mail interface due to abuse. Remember that service providers are there to make money - not offer one a service via bulk SMS's can be send.
    Some service providers have dial-up servers that works like the old style bulletin board systems (BBS's) of the 90's. You use a telnet like interface, dial into this BBS, and is prompted for mobile number, message to deliver, and even delivery confirmation. You can expect the cost of this phone call to this system, to also cover the cost of sending the SMS.
    Some companies provide a software server to interface with one or more service providers - this allows you to fairly easily use this server gateway to send SMS's for you. Such a gateway server will typically support a telnet interface - allowing you to send SMS's via it from inside PL/SQL.
    I've used all these options, and I've found the best one to be the last option. It is the easiest to use from a programming perspective. It comes with various management and reporting tools. So you need to do the very minimal in managing this whole SMS interface.

  • How to send SMS to a group

    In my earlier Nokia phone, I was able to group my friends. The usefulness was that I could send sms to all of them just by typing the Group name in the "To" field. Is there a similar feature in iphone 5? Presently am adding the names one by one, even when I know have to send sms to all 10 of them.

    No the phone doesn't recognize groups in that way. One by one is the only way to add them to the group. Submit your feedback to apple about that here: http://www.apple.com/feedback/

  • Problem in sending SMS via using java communication API

    I need to send SMS via my sony ericsson Z530i. It is connected to the com5 port of my system. I got the following code.
    import java.io.*;
    import java.util.BitSet;
    import javax.comm.*;
    import java.lang.*;
    public class SerialToGsm {
        InputStream in;
        OutputStream out;
        String lastIndexRead;
        String senderNum;
        String smsMsg;
        SerialToGsm(String porta) {
            try {
    //            CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("com5");
                CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(porta);
                SerialPort sp = (SerialPort)portId.open("Sms_GSM", 0);
                sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
                sp.setFlowControlMode(sp.FLOWCONTROL_NONE);
                in = sp.getInputStream();
                out = sp.getOutputStream();
                // modem reset
                sendAndRecv("+++AT", 30);       // delay for 20 sec/10
                sendAndRecv("AT&F", 30);
                sendAndRecv("ATE0", 30);        // echo off
                sendAndRecv("AT +CMEE=1", 30);  // verbose error messages
                sendAndRecv("AT+CMGF=0", 70);   // set pdu mode
    //            sendAndRecv("AT V1E0S0=0&D2&C1", 1000000);
            catch (Exception e) {
                System.out.println("Exception " + e);
             System.exit(1);
        private String sendAndRecv(String s, int timeout) {
            try {
                // clean serial port input buffer
                in.skip(in.available());
                System.out.println("=> " + s);
                s = s + "\r";         // add CR
                out.write(s.getBytes());
                out.flush();           
                String strIn = new String();
                for (int i = 0; i < timeout; i++){
                    int numChars = in.available();
                    if (numChars > 0) {
                        byte[] bb = new byte[numChars];
                        in.read(bb,0,numChars);
                        strIn += new String(bb);
                    // start exit conditions
                    if (strIn.indexOf(">\r\n") != -1) {
                        break;
                    if (strIn.indexOf("OK\r\n") != -1){
                        break;
                    if (strIn.indexOf("ERROR") != -1) { // if find 'error' wait for CR+LF
                        if (strIn.indexOf("\r\n",strIn.indexOf("ERROR") + 1) != -1) {
                            break;                                            
              Thread.sleep(100); // delay 1/10 sec
                System.out.println("<= " + strIn);
                if (strIn.length() == 0) {
                    return "ERROR: len 0";
                return strIn;
            catch (Exception e) {                 
                System.out.println("send e recv Exception " + e);
                return "ERROR: send e recv Exception";
        public String sendSms (String numToSend, String whatToSend) {
            ComputeSmsData sms = new ComputeSmsData();
            sms.setAsciiTxt(whatToSend);
            sms.setTelNum(numToSend);
    //        sms.setSMSCTelNum("+393359609600");  // SC fixed
            String s = new String();
            s = sendAndRecv("AT+CMGS=" + (sms.getCompletePduData().length() / 2) + "\r", 30);
    //        System.out.println("==> AT+CMGS=" + (sms.getCompletePduData().length() / 2));
    //        System.out.println("<== " + s);
            if (s.indexOf(">") != -1) {
    //            s = sendAndRecv(sms.getSMSCPduData() + sms.getCompletePduData() + "\u001A"); // usefull one day?
    //            System.out.println("Inviero questo >>>> " + sms.getCompletePduData());
                   // if this sintax won't work try remove 00 prefix
                s = sendAndRecv("00" + sms.getCompletePduData() + "\u001A", 150);
    //            System.out.println("<== " + s);
                return s;
            else {
                return "ERROR";
        // used to reset message data
        private void resetGsmObj() {
            lastIndexRead = null;
            senderNum = null;
            smsMsg = null;
        public String checkSms (){
            String str = new String();
            String strGsm = new String();                         
            strGsm = sendAndRecv("AT+CMGL=0", 30);  // list unread msg and sign them as read
            // if answer contain ERROR then ERROR
            if (strGsm.indexOf("ERROR") != -1) {
                resetGsmObj();
                return strGsm; // error
            strGsm = sendAndRecv("AT+CMGL=1", 30);  // list read msg
            // if answer contain ERROR then ERROR
            if (strGsm.indexOf("ERROR") != -1) {
                resetGsmObj();
                return strGsm; // error
            // evaluate message index
            if (strGsm.indexOf(':') <= 0) {
                resetGsmObj();
                return ("ERROR unexpected answer");
            str = strGsm.substring(strGsm.indexOf(':') + 1,strGsm.indexOf(','));
            str = str.trim(); // remove white spaces
    //        System.out.println("Index: " + str);
            lastIndexRead = str;
            // find message string
            // look for start point (search \r, then skip \n, add and one more for right char
            int startPoint = strGsm.indexOf("\r",(strGsm.indexOf(":") + 1)) + 2;
            int endPoint = strGsm.indexOf("\r",startPoint + 1);
            if (endPoint == -1) {
                // only one message
                endPoint = strGsm.length();
            // extract string
            str = strGsm.substring(startPoint, endPoint);
            System.out.println("String to be decoded :" + str);
            ComputeSmsData sms = new ComputeSmsData();
            sms.setRcvdPdu(str);
    //        SMSCNum = new String(sms.getRcvdPduSMSC());
            senderNum = new String(sms.getRcvdSenderNumber());
            smsMsg = new String(sms.getRcvdPduTxt());
            System.out.println("SMSC number:   " + sms.getRcvdPduSMSC());
            System.out.println("Sender number: " + sms.getRcvdSenderNumber());
            System.out.println("Message: " + sms.getRcvdPduTxt());
            return "OK";
        public String readSmsSender() {
            return senderNum;
        public String readSms() {
            return smsMsg;
        public String delSms() {  
            if (lastIndexRead != "") {               
                return sendAndRecv("AT+CMGD=" + lastIndexRead, 30);
            return ("ERROR");
    }When i compile, there is no error. But when i execute it, the following error comes:
    E:\java\JavaSmsApi>javac SerialToGsm.java
    E:\java\JavaSmsApi>java SerialToGsm
    Exception in thread "main" java.lang.NoSuchMethodError: main
    What might be the error? Somebody help me. Thanks in advance.

    You are probably trying to run this as a CLDC application instead of a MIDP application (aka a MIDLet). Since CLDC apps start with a main(....) your runtime looks for one but does not find it, hence the error. Please recheck the project configuration.

  • How will you send SMS by using any  java technology

    how will you send SMS by using any java technology

    Wikipedia has an entry on that protocol...
    http://en.wikipedia.org/wiki/SMPP
    Written by a 12 year old and edited by a H.S. student with a C+ average (or vice versa), so you know it's accuracy has been verified and you can trust your career on it!
    OK, I don't know that is true and you probably guessed it, but I'm not a big fan of the Wikipedia concept, but that doesn't matter as long as you understand that the information contained within Wikipedia is not vetted in any traditional way. And yes, I do use Wikipedia occasionally as a resource but I do it knowing that accuracy of the information is always in question.
    Probably doesn't need discussing in this forum, but if you are curious, there was on interesting discussion about Wikipedia here:
    http://online.wsj.com/public/article/SB115756239753455284-zM_NmQpDWtRRSoHcPYcbQ6iq4H4_20061011.html?mod=tff_main_tff_top

Maybe you are looking for