forked from microsoft/LUIS-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall-endpoint.java
More file actions
60 lines (46 loc) · 1.95 KB
/
Copy pathcall-endpoint.java
File metadata and controls
60 lines (46 loc) · 1.95 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
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
// You need to add the following Apache HTTP client libraries to your project:
// httpclient-4.5.3.jar
// httpcore-4.4.6.jar
// commons-logging-1.2.jar
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class LuisGetRequest {
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
// The ID of a public sample LUIS app that recognizes intents for turning on and off lights
String AppId = "df67dcdb-c37d-46af-88e1-8b97951ca1c2";
// Add your subscription key
String SubscriptionKey = "YOUR-SUBSCRIPTION-KEY";
URIBuilder builder =
new URIBuilder("https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" + AppId + "?");
builder.setParameter("q", "turn on the left light");
builder.setParameter("timezoneOffset", "0");
builder.setParameter("verbose", "false");
builder.setParameter("spellCheck", "false");
builder.setParameter("staging", "false");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", SubscriptionKey);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}