Send sms via java from java application -


i writing java program must able send sms. i'm inspired post here code

string url = "http://www.mobinawa.com/http_api";         string charset = "utf-8";  // or in java 7 , later, use constant: java.nio.charset.standardcharsets.utf_8.name()         string param1 = "sendsms";         string param2 = "696926448";         string param3 = "pwd";         string param4 = "hereka";         string param5 = phonenumber.replace("+237", "");         string param6 = textmessage;          string query = string.format("action=%s&username=%s&password=%s&from=%s&to=%s&msg=%s",          urlencoder.encode(param1, charset),          urlencoder.encode(param2, charset),         urlencoder.encode(param3, charset),          urlencoder.encode(param4, charset),         urlencoder.encode(param5, charset),          urlencoder.encode(param6, charset));             /*         urlconnection connection = new url(url + "?" + query).openconnection();         connection.setrequestproperty("accept-charset", charset);*/           urlconnection connection = new url(url).openconnection();         connection.setdooutput(true); // triggers post.         connection.setrequestproperty("accept-charset", charset);         connection.setrequestproperty("content-type", "application/x-www-form-urlencoded;charset=" + charset);         try (outputstream output = connection.getoutputstream()) {             output.write(query.getbytes(charset));         }            inputstream response = connection.getinputstream();         try (scanner scanner = new scanner(response)) {             string responsebody = scanner.usedelimiter("\\a").next();             system.out.println(responsebody);         } 

when execute answer printed sms not sent, don't understand why. here in console

<!doctype html public "-//ietf//dtd html 2.0//en"> <html>     <head>         <title></title>         <meta name="description" content="">         <meta name="keywords" content="">         <meta name="generator" content="ort - ovh redirect technology">         <meta name="url" content="http://digitalmarketing.gts-africa.com/http_api">         <meta name="robots" content="all">     </head>     <frameset rows="100%,0" frameborder=no border=0>         <frame name="ort" src="http://digitalmarketing.gts-africa.com/http_api">         <frame name="none" src="" scrolling="no" noresize>         <noframes>             <body><a href="http://digitalmarketing.gts-africa.com/http_api">click here</a><hr></body>         </noframes>     </frameset> </html> 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -