Skip to content

Commit 0d70104

Browse files
authored
Merge pull request #115777 from dksimpson/DKS-US1712683-bing-web-search
Refresh Bing Web Search REST API quickstarts
2 parents e205151 + 1a0f533 commit 0d70104

File tree

9 files changed

+134
-97
lines changed

9 files changed

+134
-97
lines changed

articles/cognitive-services/Bing-Web-Search/quickstarts/csharp.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: bing-web-search
1010
ms.topic: quickstart
11-
ms.date: 12/09/2019
11+
ms.date: 05/22/2020
1212
ms.author: aahi
1313
ms.custom: seodec2018
1414
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using C#.
1515
---
1616

1717
# Quickstart: Search the web using the Bing Web Search REST API and C#
1818

19-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This C# application sends a search request to the API, and shows the response. While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
19+
Use this quickstart to make your first call to the Bing Web Search API. This C# application sends a search request to the API, and shows the JSON response. Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
20+
21+
This example program in this quickstart uses only .NET Core classes.
2022

2123
## Prerequisites
2224

@@ -26,13 +28,11 @@ Here are a few things that you'll need before running this quickstart:
2628
* Linux/macOS: [Mono](https://www.mono-project.com/)
2729
* A subscription key
2830

29-
This example program only uses .NET Core classes.
30-
3131
[!INCLUDE [bing-web-search-quickstart-signup](../../../../includes/bing-web-search-quickstart-signup.md)]
3232

3333
## Create a project and declare dependencies
3434

35-
Create a new project in Visual Studio or Mono. Then use this code to import required namespaces and types.
35+
Create a new project in Visual Studio or Mono. Use the following code to import the required namespaces and types:
3636

3737
```csharp
3838
using System;
@@ -58,7 +58,13 @@ namespace BingSearchApisQuickstart
5858

5959
## Define variables
6060

61-
A few variables must be set before we can continue. `uriBase` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that the `uriBase` is valid and replace the `accessKey` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `searchTerm`. Remember to add this code to the `Program` class as noted above.
61+
A few variables must be set before we can continue. Add this code to the `Program` class you created in the previous section:
62+
63+
1. For the `uriBase` value, 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.
64+
65+
2. Confirm that `uriBase` is valid and replace the `accessKey` value with a subscription key from your Azure account.
66+
67+
3. Optionally, customize the search query by replacing the value for `searchTerm`.
6268

6369
```csharp
6470
// Enter a valid subscription key.
@@ -74,9 +80,9 @@ const string searchTerm = "Microsoft Cognitive Services";
7480

7581
## Declare the Main method
7682

77-
The `Main()` method is required and it's the first method invoked when the program is started. In this application, the main method validates the `accessKey`, makes a request, and prints the response.
83+
The `Main()` method is required and is the first method invoked when you start the program. In this application, the main method validates the `accessKey`, makes a request, and prints the response.
7884

79-
Keep in mind that `main()` is dependent on methods that are created in the next few sections.
85+
The `main()` method is dependent on methods that you create in the next sections.
8086

8187
```csharp
8288
static void Main()
@@ -105,7 +111,7 @@ static void Main()
105111

106112
## Create a struct for search results
107113

108-
This struct returns search results with relevant headers. It's called when making a request to the Bing Web Search API to create a result object.
114+
Create a struct that returns search results with relevant headers. You call it when you make a request to the Bing Web Search API to create a result object.
109115

110116
```csharp
111117
// Returns search results with headers.
@@ -154,7 +160,7 @@ static SearchResult BingWebSearch(string searchQuery)
154160

155161
## Format the response
156162

157-
This method formats the JSON response, primarily indenting and adding line breaks.
163+
This method formats the JSON response, primarily by indenting and adding line breaks.
158164

159165
```csharp
160166
/// <summary>
@@ -231,9 +237,9 @@ static string JsonPrettyPrint(string json)
231237

232238
## Put it all together
233239

234-
The last step is to run your code! If you'd like to compare your code with ours, [sample code is available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingWebSearchv7.cs).
240+
The last step is to run your code. If you'd like to compare your code with ours, see the [sample code on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingWebSearchv7.cs).
235241

236-
## Sample response
242+
## Example JSON response
237243

238244
Responses from the Bing Web Search API are returned as JSON. This sample response has been truncated to show a single result.
239245

@@ -362,6 +368,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
362368
## Next steps
363369

364370
> [!div class="nextstepaction"]
365-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
371+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
366372
367373
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

articles/cognitive-services/Bing-Web-Search/quickstarts/go.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: bing-web-search
1010
ms.topic: quickstart
11-
ms.date: 12/09/2019
11+
ms.date: 05/22/2020
1212
ms.author: aahi
1313
ms.reviewer: [email protected], v-gedod, erhopf
1414
ms.custom: seodec2018
@@ -17,21 +17,21 @@ ms.custom: seodec2018
1717

1818
# Quickstart: Search the web using the Bing Web Search REST API and Go
1919

20-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This Go application sends a search request to the API, and shows the response. While this application is written in Go, the API is a RESTful Web service compatible with most programming languages.
20+
Use this quickstart to make your first call to the Bing Web Search API. This Go application sends a search request to the API, and shows the JSON response. Although this application is written in Go, the API is a RESTful Web service compatible with most programming languages.
21+
22+
The code examples in this quickstart require only core libraries; there are no external dependencies.
2123

2224
## Prerequisites
2325
Here are a few things that you'll need before running this quickstart:
2426

2527
* [Go binaries](https://golang.org/dl/)
2628
* A subscription key
2729

28-
This quickstart only requires **core** libraries, there are no external dependencies.
29-
3030
[!INCLUDE [bing-web-search-quickstart-signup](../../../../includes/bing-web-search-quickstart-signup.md)]
3131

3232
## Create a project and import core libraries
3333

34-
Create a new Go project in your favorite IDE or editor. Then import `net/http` for requests, `ioutil` to read the response, `time` and `encoding/json` to handle the JSON, and `fmt` to print the output.
34+
Create a new Go project in your favorite IDE or editor. Then, import `net/http` for requests, `ioutil` to read the response, `time` and `encoding/json` to handle the JSON, and `fmt` to print the output.
3535

3636
```go
3737
package main
@@ -107,7 +107,13 @@ type BingAnswer struct {
107107

108108
## Declare the main function and define variables
109109

110-
This code declares the main function and sets required variables. `endpoint` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that the endpoint is correct and replace the `token` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `searchTerm`.
110+
This code declares the main function and sets the required variables:
111+
112+
1. For the `endpoint` value, 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.
113+
114+
2. Confirm that the endpoint is correct and replace the `token` value with a valid subscription key from your Azure account.
115+
116+
3. Optionally, customize the search query by replacing the value for `searchTerm`.
111117

112118
```go
113119
// Declare the main function. This is required for all Go programs.
@@ -166,7 +172,7 @@ if err != nil {
166172

167173
## Handle the response
168174

169-
Remember the struct we created earlier? We're going to use it to format the response and print the search results.
175+
Use the struct we created previously to format the response and print the search results.
170176

171177
```go
172178
// Create a new answer.
@@ -183,7 +189,7 @@ for _, result := range ans.WebPages.Value {
183189

184190
## Put it all together
185191

186-
The last step is to validate your code and run it! If you'd like to compare your code with ours, here's the complete program:
192+
The last step is to validate your code and run it. If you'd like to compare your code with ours, here's the complete program:
187193

188194
```go
189195
package main
@@ -301,9 +307,9 @@ func main() {
301307
}
302308
```
303309

304-
## Sample response
310+
## Example JSON response
305311

306-
Responses from the Bing Web Search API are returned as JSON. This sample response has been formatted using the `BingAnswer` struct and shows the `result.Name` and `result.URL`.
312+
Responses from the Bing Web Search API are returned as JSON. This sample response has been formatted by using the `BingAnswer` struct and shows the `result.Name` and `result.URL`.
307313

308314
```go
309315
Microsoft Cognitive Services || https://www.microsoft.com/cognitive-services
@@ -320,6 +326,6 @@ Cognitive Services - msdn.microsoft.com || https://msdn.microsoft.com/magazine/m
320326
## Next steps
321327

322328
> [!div class="nextstepaction"]
323-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
329+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
324330
325331
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

articles/cognitive-services/Bing-Web-Search/quickstarts/java.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: bing-web-search
1010
ms.topic: quickstart
11-
ms.date: 12/09/2019
11+
ms.date: 05/22/2020
1212
ms.author: aahi
1313
ms.custom: seodec2018, seo-java-july2019, seo-java-august2019, seo-java-september2019
1414
#Customer intent: As a new developer, I want to make my first call to the Bing Web Search API and receive a response using Java.
1515
---
1616

1717
# Quickstart: Use Java to search the web with the Bing Web Search REST API, an Azure cognitive service
1818

19-
In this quickstart, you'll use a Java application to make your first call to the Bing Web Search API and receive the JSON response. This Java application sends a search request to the API, and shows the response. While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
19+
In this quickstart, you'll use a Java application to make your first call to the Bing Web Search API. This Java application sends a search request to the API, and shows the JSON response. Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
2020

2121
## Prerequisites
2222

@@ -45,7 +45,7 @@ import com.google.gson.JsonParser;
4545

4646
### Declare Gson in the Maven POM file
4747

48-
If you're using Maven, declare Gson in the `POM.xml`. Skip this step if you've installed Gson locally.
48+
If you're using Maven, declare Gson in POM.xml. Skip this step if you've installed Gson locally.
4949

5050
```xml
5151
<dependency>
@@ -57,7 +57,7 @@ If you're using Maven, declare Gson in the `POM.xml`. Skip this step if you've i
5757

5858
## Declare the BingWebSearch class
5959

60-
Declare the `BingWebSearch` class. It will include most of the code we review in this quickstart including the `main` method.
60+
Declare the `BingWebSearch` class. It includes most of the code we review in this quickstart, including the `main()` method.
6161

6262
```java
6363
public class BingWebSearch {
@@ -69,7 +69,13 @@ public class BingWebSearch {
6969

7070
## Define variables
7171

72-
This code sets the `subscriptionKey`, `host`, `path`, and `searchTerm`. `host` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Replace the `subscriptionKey` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `searchTerm`. Remember to add this code to the `BingWebSearch` class as noted above.
72+
The following code sets the `subscriptionKey`, `host`, `path`, and `searchTerm`. Add this code to the `BingWebSearch` class described in the previous section:
73+
74+
1. For the `host` value, 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.
75+
76+
2. Replace the `subscriptionKey` value with a valid subscription key from your Azure account.
77+
78+
3. Optionally, customize the search query by replacing the value for `searchTerm`.
7379

7480
```java
7581
// Enter a valid subscription key.
@@ -87,7 +93,7 @@ static String searchTerm = "Microsoft Cognitive Services";
8793

8894
## Construct a request
8995

90-
This method, which lives in the `BingWebSearch` class, constructs the `url`, receives and parses the response, and extracts Bing-related HTTP headers.
96+
The `SearchWeb()` method, which is included in the `BingWebSearch` class, constructs the `url`, receives and parses the response, and extracts Bing-related HTTP headers.
9197

9298
```java
9399
public static SearchResults SearchWeb (String searchQuery) throws Exception {
@@ -133,7 +139,7 @@ public static String prettify(String json_text) {
133139

134140
## Declare the main method
135141

136-
This method is required and is the first method invoked when the program is started. In this application, it includes code that validates the `subscriptionKey`, makes a request, and prints the JSON response.
142+
The `main()` method is required and is the first method invoked when you start the program. In this application, it includes code that validates the `subscriptionKey`, makes a request, and then prints the JSON response.
137143

138144
```java
139145
public static void main (String[] args) {
@@ -163,7 +169,7 @@ public static void main (String[] args) {
163169

164170
## Create a container class for search results
165171

166-
The `SearchResults` container class is outside of the `BingWebSearch` class. It includes relevant headers and JSON data for the response.
172+
The `SearchResults` container class is defined outside of the `BingWebSearch` class. It includes relevant headers and JSON data for the response.
167173

168174
```java
169175
class SearchResults{
@@ -178,7 +184,7 @@ class SearchResults{
178184

179185
## Put it all together
180186

181-
The last step is to compile your code and run it! Here are the commands:
187+
The last step is to compile your code and run it. Use the following commands:
182188

183189
```powershell
184190
javac BingWebSearch.java -classpath ./gson-2.8.5.jar -encoding UTF-8
@@ -187,7 +193,7 @@ java -cp ./gson-2.8.5.jar BingWebSearch
187193

188194
If you'd like to compare your code with ours, [sample code is available on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingWebSearchv7.java).
189195

190-
## Sample response
196+
## Example JSON response
191197

192198
Responses from the Bing Web Search API are returned as JSON. This sample response has been truncated to show a single result.
193199

@@ -316,6 +322,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
316322
## Next steps
317323

318324
> [!div class="nextstepaction"]
319-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
325+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
320326
321327
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

0 commit comments

Comments
 (0)