-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakeCall.java
45 lines (38 loc) · 1.73 KB
/
MakeCall.java
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
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.client.methods.HttpUriRequest;
import java.net.URI;
import java.nio.charset.Charset;
public class MakeCall {
public static void main(String[] args) {
try {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope("api.46elks.com", 443),
new UsernamePasswordCredentials(
"<API Username>",
"<API Password>"));
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
HttpUriRequest postrequest = RequestBuilder.post()
.setUri(new URI("https://api.46elks.com/a1/Calls"))
.addParameter("from", "elkme")
.addParameter("to", "+46723175800")
.addParameter("voice_start", '{"connect":"+461890510"}')
.build();
CloseableHttpResponse response = httpclient.execute(postrequest);
System.out.println(response.getStatusLine());
response.close();
httpclient.close();
} catch (Exception e){
System.out.println(e);
}
}
}