You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/csharp.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,15 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-entity-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/11/2019
12
+
ms.date: 05/08/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Send a search request to the Bing Entity Search REST API using C#
17
17
18
18
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple C# application sends a news search query to the API, and displays the response. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingEntitySearchv7.cs).
19
19
20
-
While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
20
+
Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
21
21
22
22
23
23
## Prerequisites
@@ -26,18 +26,18 @@ While this application is written in C#, the API is a RESTful Web service compat
26
26
27
27
- The [Json.NET](https://www.newtonsoft.com/json) framework, available as a NuGet package. To install the NuGet package in Visual Studio:
28
28
29
-
1. Rightclick your project in **Solution Explorer**.
29
+
1. Right-click your project in **Solution Explorer**.
30
30
2. Select **Manage NuGet Packages**.
31
-
3. Search for *Newtonsoft.Json* and install the package.
31
+
3. Search for and select *Newtonsoft.Json*, and then install the package.
32
32
33
-
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
33
+
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
1.create a new C# console solution in Visual Studio. Then add the following namespaces into the main code file.
40
+
1.Create a new C# console solution in Visual Studio. Then, add the following namespaces into the main code file:
41
41
42
42
```csharp
43
43
usingNewtonsoft.Json;
@@ -46,7 +46,7 @@ While this application is written in C#, the API is a RESTful Web service compat
46
46
usingSystem.Text;
47
47
```
48
48
49
-
2. Createanew class, and add variables for the API endpoint, your subscription key, and query you want to search. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
49
+
2. Createanew class, and add variables for the API endpoint, your subscription key, and the query you want to search. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
50
50
51
51
```csharp
52
52
namespace EntitySearchSample
@@ -69,11 +69,13 @@ While this application is written in C#, the API is a RESTful Web service compat
69
69
70
70
## Send a request and get the API response
71
71
72
-
1. Withinthe class, create a function called `Search()`. Create a new `HttpClient` object, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
72
+
1. Withinthe class, create a function called `Search()`. Within this function, create a new `HttpClient` object, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
73
73
74
-
1. Construct the URI for your request by combining the host and path. Then add your market, and URL-encode your query.
75
-
2. Await `client.GetAsync()` to get a HTTP response, and then store the json response by awaiting `ReadAsStringAsync()`.
76
-
3. Format the JSON string with `JsonConvert.DeserializeObject()` and print it to the console.
74
+
2. Construct the URI for your request by combining the host and path. Then, add your market and URL-encode your query.
75
+
76
+
3. Await `client.GetAsync()` to get an HTTP response, and then store the JSON response by awaiting `ReadAsStringAsync()`.
77
+
78
+
4. Format the JSON string with `JsonConvert.DeserializeObject()` and print it to the console.
77
79
78
80
```csharp
79
81
async static void Search()
@@ -92,7 +94,7 @@ While this application is written in C#, the API is a RESTful Web service compat
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/java.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,26 +9,26 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-entity-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/11/2019
12
+
ms.date: 05/08/2020
13
13
ms.author: aahi
14
14
---
15
15
# Quickstart: Send a search request to the Bing Entity Search REST API using Java
16
16
17
17
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple Java application sends a news search query to the API, and displays the response.
18
18
19
-
While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
19
+
Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
20
20
21
21
## Prerequisites
22
22
23
-
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/)
24
-
* The [Gson library](https://github.com/google/gson)
23
+
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/).
24
+
* The [Gson library](https://github.com/google/gson).
1. Create a new Java project in your favorite IDE or editor, and import the following libraries.
31
+
1. Create a new Java project in your favorite IDE or editor, and import the following libraries:
32
32
33
33
```java
34
34
importjava.io.*;
@@ -45,7 +45,7 @@ While this application is written in Java, the API is a RESTful Web service comp
45
45
importcom.google.gson.JsonParser;
46
46
```
47
47
48
-
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
48
+
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
49
49
50
50
```java
51
51
publicclassEntitySearch {
@@ -63,7 +63,7 @@ While this application is written in Java, the API is a RESTful Web service comp
63
63
64
64
## Construct a search request string
65
65
66
-
1.Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`.Add your market to the string with `?mkt=`.
66
+
1.Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`.Add your market to the parameter string with `?mkt=`.
67
67
68
68
2.Create a URL object with your host, path, and parameters strings.
69
69
@@ -99,7 +99,7 @@ While this application is written in Java, the API is a RESTful Web service comp
99
99
//...
100
100
```
101
101
102
-
3.Create a `String` object to store the response from the `BufferedReader`.Iterate through it, and append each line to the string. Then close the reader, and return the response.
102
+
3.Create a `String` object to store the response from the `BufferedReader`.Iterate through it, and append each line to the string. Then, close the reader and return the response.
103
103
104
104
```java
105
105
String line;
@@ -114,9 +114,9 @@ While this application is written in Java, the API is a RESTful Web service comp
114
114
115
115
## Format the JSON response
116
116
117
-
1.Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, and call `parse()` on the json text, and store it as a JSON object.
117
+
1.Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, call `parse()` on the JSON text, and then store it as a JSON object.
118
118
119
-
2.Use the Gson library to create a new `GsonBuilder()`, and use `setPrettyPrinting().create()` to format the json. Thenreturn it.
119
+
2.Use the Gson library to create a new `GsonBuilder()`, use `setPrettyPrinting().create()` to format the JSON, and thenreturn it.
120
120
121
121
```java
122
122
//...
@@ -131,7 +131,7 @@ While this application is written in Java, the API is a RESTful Web service comp
131
131
132
132
## Call the search function
133
133
134
-
1.From the main method of your project, call `search()`, and use `prettify()` to format the text.
134
+
-From the main method of your project, call `search()`, and use `prettify()` to format the text.
135
135
136
136
```java
137
137
publicstaticvoid main(String[] args) {
@@ -215,5 +215,5 @@ A successful response is returned in JSON, as shown in the following example:
215
215
> [!div class="nextstepaction"]
216
216
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
217
217
218
-
* [What is the BingEntitySearchAPI?](../overview.md)
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/nodejs.md
+42-41Lines changed: 42 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,34 +9,34 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-entity-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/11/2019
12
+
ms.date: 05/08/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Send a search request to the Bing Entity Search REST API using Node.js
17
17
18
18
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple JavaScript application sends a news search query to the API, and displays the response. The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingEntitySearchv7.js).
19
19
20
-
While this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
20
+
Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
21
21
22
22
## Prerequisites
23
23
24
24
* The latest version of [Node.js](https://nodejs.org/en/download/).
25
25
26
-
* The [JavaScript Request Library](https://github.com/request/request)
26
+
* The [JavaScript Request Library](https://github.com/request/request).
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and https requirements.
32
+
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and HTTPS requirements.
33
33
34
34
```javaScript
35
35
'use strict';
36
36
let https =require ('https');
37
37
```
38
38
39
-
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
39
+
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
40
40
41
41
```javascript
42
42
let subscriptionKey = 'ENTER YOUR KEY HERE';
@@ -54,52 +54,53 @@ While this application is written in JavaScript, the API is a RESTful Web servic
54
54
55
55
## Handle and parse the response
56
56
57
-
1. Define a function named `response_handler` that takes an HTTP call, `response`, as a parameter. Within this function, perform the following steps:
57
+
1. Define a function named `response_handler()` that takes an HTTP call, `response`, as a parameter.
58
58
59
-
1. Define a variable to contain the body of the JSON response.
60
-
```javascript
61
-
let response_handler = function (response) {
62
-
let body ='';
63
-
};
64
-
```
59
+
2. Within this function, define a variable to contain the body of the JSON response.
60
+
```javascript
61
+
let response_handler = function (response) {
62
+
let body ='';
63
+
};
64
+
```
65
65
66
-
2. Store the body of the response when the **data** flag is called
67
-
```javascript
68
-
response.on('data', function (d) {
69
-
body += d;
70
-
});
71
-
```
66
+
3. Store the body of the response when the `data` flag is called.
67
+
```javascript
68
+
response.on('data', function (d) {
69
+
body += d;
70
+
});
71
+
```
72
72
73
-
3. When an **end** flag is signaled, parse the JSON, and print it.
73
+
4. When an `end` flag is signaled, parse the JSON, and print it.
74
74
75
-
```javascript
76
-
response.on ('end', function () {
77
-
let json = JSON.stringify(JSON.parse(body), null, ' ');
78
-
console.log (json);
79
-
});
75
+
```javascript
76
+
response.on ('end', function () {
77
+
let json = JSON.stringify(JSON.parse(body), null, ' ');
78
+
console.log (json);
79
+
});
80
80
```
81
81
82
82
## Send a request
83
83
84
-
1. Create a function called `Search` to send a search request. In it, perform the following steps.
84
+
1. Create a function called `Search()` to send a search request. In it, perform the following steps:
85
+
86
+
2. Within this function, create a JSON object containing your request parameters. Use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
85
87
86
-
1. Create a JSON object containing your request parameters: use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
87
-
2. Use `https.request()` to send the request with the response handler created earlier, and your search parameters.
88
+
3. Use `https.request()` to send the request with the response handler created previously, and your search parameters.
88
89
89
-
```javascript
90
-
let Search = function () {
91
-
let request_params = {
92
-
method :'GET',
93
-
hostname : host,
94
-
path : path + query,
95
-
headers : {
96
-
'Ocp-Apim-Subscription-Key': subscriptionKey,
97
-
}
98
-
};
90
+
```javascript
91
+
let Search = function () {
92
+
let request_params = {
93
+
method :'GET',
94
+
hostname : host,
95
+
path : path + query,
96
+
headers : {
97
+
'Ocp-Apim-Subscription-Key': subscriptionKey,
98
+
}
99
+
};
99
100
100
-
let req =https.request (request_params, response_handler);
101
-
req.end ();
102
-
}
101
+
let req =https.request (request_params, response_handler);
102
+
req.end ();
103
+
}
103
104
```
104
105
105
106
2. Call the `Search()`function.
@@ -175,4 +176,4 @@ A successful response is returned in JSON, as shown in the following example:
175
176
> [Build a single-page web app](../tutorial-bing-entities-search-single-page-app.md)
176
177
177
178
*[What is the Bing Entity Search API?](../overview.md)
178
-
*[Bing Entity Search API Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference)
179
+
*[Bing Entity Search API reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-entities-api-v7-reference).
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Entities-Search/quickstarts/php.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,15 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-entity-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/11/2019
12
+
ms.date: 05/08/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Send a search request to the Bing Entity Search REST API using PHP
17
17
18
18
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple PHP application sends a news search query to the API, and displays the response.
19
19
20
-
While this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
20
+
Although this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
21
21
22
22
## Prerequisites
23
23
@@ -27,12 +27,12 @@ While this application is written in PHP, the API is a RESTful Web service compa
27
27
28
28
## Search entities
29
29
30
-
To run this application, follow these steps.
30
+
To run this application, follow these steps:
31
31
32
32
1. Create a new PHP project in your favorite IDE.
33
33
2. Add the code provided below.
34
34
3. Replace the `key` value with an access key valid for your subscription.
35
-
4. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
35
+
4. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
0 commit comments