forked from loopccoew/Buffer_3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSMS.java
More file actions
65 lines (41 loc) · 1.37 KB
/
SMS.java
File metadata and controls
65 lines (41 loc) · 1.37 KB
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
59
60
61
62
63
64
65
package e_mess_management;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;
import javax.net.ssl.HttpsURLConnection;
public class SMS {
public void sendSms(String message,String number)
{
try
{
String apiKey="TMEJpvPlBRNeFcAoIbZx6LduHQKYr4G7yhiwgzU0SXV3Wqf9s27EIOx83si2UNJHw40fmZyDKLeq5jRQ";
String sendId="FastSM";
//important step...
message=URLEncoder.encode(message, "UTF-8");
String language="english";
String route="p";
String myUrl="https://www.fast2sms.com/dev/bulk?authorization="+apiKey+"&sender_id="+sendId+"&message="+message+"&language="+language+"&route="+route+"&numbers="+number;
//sending get request using java..
URL url=new URL(myUrl);
HttpsURLConnection con=(HttpsURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("cache-control", "no-cache");
StringBuffer response=new StringBuffer();
BufferedReader br=new BufferedReader(new InputStreamReader(con.getInputStream()));
while(true)
{
String line=br.readLine();
if(line==null)
{
break;
}
response.append(line);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}