smslib - Send SMS in java using site2SMS/way2sms -


the following code send sms in java language,

import java.net.*; import java.io.*; import java.util.scanner;  public class site2sms {     //replace site2sms username , password below     static final string _username = "username";     static final string _password = "password";     static final string _url = "http://smsapi.cikly.in/index.php";       //static final string _url = "http://smsapi.cikly.in/index.php";     //static final string _url = "http://www.site2sms.com/user/send_sms_next.asp";     static final string charset = "utf-8";      //to build query string send message     private static string buildrequeststring(string targetphoneno, string message) throws unsupportedencodingexception     {         string [] params = new string [5];         params[0] = _username;         params[1] = _password;         params[2] = message;         params[3] = targetphoneno;         params[4] = "site2sms";          string query = string.format("uid=%s&pwd=%s&msg=%s&phone=%s&provider=%s",         urlencoder.encode(params[0],charset),         urlencoder.encode(params[1],charset),         urlencoder.encode(params[2],charset),         urlencoder.encode(params[3],charset),         urlencoder.encode(params[4],charset)         );     return query;     }      public static void sendmessage(string reciever, string message) throws exception     {          system.out.println("hi!hello");         //to establish connection , perform post request         urlconnection connection = new url(_url + "?" + buildrequeststring(reciever,message)).openconnection();         connection.setrequestproperty("accept-charset", charset);          //this automatically fires request , can use determine response status         inputstream response = connection.getinputstream();         bufferedreader br = new bufferedreader(new inputstreamreader(response));         //system.out.println(br);          system.out.println(br.readline());     }      public static void main(string [] args) throws exception     {         system.out.println("enter mobile no:");         scanner scanin = new scanner(system.in);          string testphoneno = scanin.nextline();         scanin.close();                     string testmessage = "sending messages java not hard";         sendmessage(testphoneno,testmessage);     } }  

when run program, there no compile error , no runtime error, message not delivered respective number.

pls me, suggestion can accepted.

thanks , regards,

it written in comments in class : replace site2sms username , password. guess have subsrcibe account in smsapi.cikly.in


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -