-
Notifications
You must be signed in to change notification settings - Fork 0
/
Freesms.jsp
58 lines (49 loc) · 1.83 KB
/
Freesms.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.io.BufferedReader" %>
<%@page import="java.io.InputStreamReader" %>
<%@page import="java.io.OutputStreamWriter" %>
<%@page import="java.net.URL" %>
<%@page import="java.net.URLConnection" %>
<%@page import="java.net.URLEncoder" %>
<%@page import="java.net.HttpURLConnection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String txt_sender=request.getParameter("txtsender");
String txt_number=request.getParameter("txtnumber");
String txt_message=request.getParameter("txtmessage");
String txt_api=("09WAKxu6mL0-D1uiCM3AMH3cA5PmGJ6vWaID3GRGVL");
try {
// Construct data
String apiKey = "apikey=" + txt_api;
String message = "&message=" + txt_message;
String sender = "&sender=" + txt_sender;
String numbers = "&numbers=" + txt_number;
// Send data
HttpURLConnection conn = (HttpURLConnection) new URL("https://api.textlocal.in/send/?").openConnection();
String data = apiKey + 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();
//return stringBuffer.toString();
} catch (Exception e) {
System.out.println("Error SMS "+e);
//return "Error "+e;
}
%>
</body>
</html>