I want to send SMS from my JAVA application in the following format:
NAME:
ConfNO client name: 1234
Date: 2012-05-15
NoOfPax: Seven
Since I use an external SMS gateway, I need to send it as a URL from the application. When I receive SMS, I do not see line breaks instead of text display \ n. Please, help. My code
String senderid = "SMSALERT";
String to = "97112345678";
String text = "Reservation INFO\nName:Customer Name\nConfNO: KN1234\nTime: 12:00PM\n#Pax:5\nThank You for Choosing US";
String type = "text";
String ppgHost = "www.yahoo.com";
String username = "username";
String password = "password";
String datetime = "2012-05-15 12:00:00";
String path = "index.php";
try {
HttpClient httpClient = new DefaultHttpClient();
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
qparams.add(new BasicNameValuePair("username", username));
qparams.add(new BasicNameValuePair("password", password));
qparams.add(new BasicNameValuePair("senderid", senderid));
qparams.add(new BasicNameValuePair("to", to));
qparams.add(new BasicNameValuePair("text", text));
qparams.add(new BasicNameValuePair("type", type));
qparams.add(new BasicNameValuePair("datetime", datetime));
URI uri = URIUtils.createURI("http", ppgHost, -1, path, URLEncodedUtils.format(qparams, "UTF-8"), null);
HttpPost httppost = new HttpPost(uri);
System.out.println(httppost.getURI());
HttpResponse response = httpClient.execute(httppost);
System.out.println(response.getStatusLine());
source
share