Skip to content

Instantly share code, notes, and snippets.

@nanborklabs
Created September 5, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanborklabs/7cb59a8b4f847c194ffa8590df27052d to your computer and use it in GitHub Desktop.
Save nanborklabs/7cb59a8b4f847c194ffa8590df27052d to your computer and use it in GitHub Desktop.
protected Void doInBackground(Void... params) {
String user = "username=" + "nandhu12195@gmail.com";
String hash = "&hash=" + "d28037624ea694bee8ff95719bf8995bedde1585";
String api = "&apiKey" + "A3kqyA4v4UA-6aqjTecsmcr7AhtnB1m1taU4ee8ywG";
String message = "&message=" + "This is your message";
String sender = "&sender=" + "KL";
String numbers = "&numbers=" + "918675753534";
try {
// Send data
HttpURLConnection conn = (HttpURLConnection) new URL("http://api.textlocal.in/send/?").openConnection();
String data = user + hash + api + numbers + message + sender;
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Length", Integer.toString(data.length()));
conn.getOutputStream().write(data.getBytes("UTF-8"));
final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
final StringBuffer stringBuffer = new StringBuffer();
String line;
while ((line = rd.readLine()) != null) {
stringBuffer.append(line);
}
rd.close();
Log.d("Async", "doInBackground: " + stringBuffer.toString());
} catch (Exception e) {
Log.d("Async", "doInBackground: ");
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment