-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall.java
More file actions
86 lines (65 loc) · 2.18 KB
/
call.java
File metadata and controls
86 lines (65 loc) · 2.18 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.awt.*;
import java.util.*;
import java.lang.*;
import java.net.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.JPanel;
public class call {
private int num = 4;
private String webSite = "https://cp52-2.fonality.com/call.cgi?";
private String[] userInfoLabel = {"server_id", "extention", "username", "password"};
private String[] userInfo;
private String phoneNumber;
private String url;
private Scanner input;
private HttpsURLConnection con;
private URI uri;
private int responseCode;
public void setupDisplay(){
}
public void input(){
System.out.println("Enter phone number: ");
input = new Scanner(System.in);
phoneNumber = input.nextLine();
phoneNumber = "number=" + phoneNumber + "&";
}
public void getUser(){
userInfo = new String[num];
for(int i = 0; i < userInfo.length; i++){
System.out.println("Enter " + userInfoLabel[i]);
userInfo[i] = input.nextLine();
}
}
public void urlConnection() throws Exception {
String urlParameters = "server_id=" + userInfo[0] + "&extension=" + userInfo[1] + "&username=" + userInfo[2] + "&password=" + userInfo[3] + "&";
url = webSite + urlParameters + phoneNumber;
URL obj = new URL(url);
con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(url);
responseCode = con.getResponseCode();
wr.flush();
wr.close();
}
public void print() throws Exception {
System.out.println("\nSending 'POST' request to URL : " + url);
// System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
//print result
System.out.println(response.toString());
}
}