Skip to content

Commit 9b6b7da

Browse files
author
dksimpson
committed
Edits
1 parent 06c1a82 commit 9b6b7da

File tree

9 files changed

+72
-38
lines changed

9 files changed

+72
-38
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ms.custom: seodec2018
1818

1919
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.
2020

21-
This example program only uses .NET Core classes.
21+
This example program in this quickstart uses only .NET Core classes.
2222

2323
## Prerequisites
2424

@@ -58,7 +58,13 @@ namespace BingSearchApisQuickstart
5858

5959
## Define variables
6060

61-
A few variables must be set before we can continue. You can use the value of `uriBase` in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that `uriBase` is valid and replace the `accessKey` value with a valid subscription key from your Azure account. You can customize the search query by replacing the value for `searchTerm`. Add this code to the `Program` class as noted in the previous section.
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 value of `uriBase` 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.
@@ -76,7 +82,7 @@ const string searchTerm = "Microsoft Cognitive Services";
7682

7783
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+
Keep in mind that `main()` is dependent on methods that you create in the next few 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, by primarily indenting and adding line breaks.
158164

159165
```csharp
160166
/// <summary>
@@ -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: 16 additions & 10 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/20/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 value of `endpoint`, 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+
We'll now 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,7 +307,7 @@ func main() {
301307
}
302308
```
303309

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

306312
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`.
307313

@@ -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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ public class BingWebSearch {
6969

7070
## Define variables
7171

72-
This code sets the `subscriptionKey`, `host`, `path`, and `searchTerm`. You can use the value of `host` in the following code for the global endpoint, or use 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. You can customize the search query by replacing the value for `searchTerm`. Add this code to the `BingWebSearch` class as noted in the previous section.
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 value of `host`, 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 is included in the `BingWebSearch` class, constructs the `url`, receives and parses the response, and extracts Bing-related HTTP headers.
96+
The `SsearchWeb()` 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 {
@@ -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{

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Here are a few things that you'll need before running this quickstart:
2929

3030
## Create a project and declare required modules
3131

32-
Create a new Node.js project in your favorite IDE or editor. Then, copy the following code snippet to your project in a file named `search.js`:
32+
Create a new Node.js project in your favorite IDE or editor. Then, copy the following code snippet to your project in a file named search.js:
3333

3434
```javascript
3535
// Use this simple app to query the Bing Web Search API and get a JSON response.
@@ -52,9 +52,15 @@ if (!SUBSCRIPTION_KEY) {
5252

5353
## Create a function to make the request
5454

55-
This function makes a secure GET request and saves the search query as a query parameter in the path. You can use the value of `hostname` in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
55+
This function makes a secure GET request and saves the search query as a query parameter in the path.
5656

57-
In this function, `encodeURIComponent` is used to escape invalid characters, and the subscription key is passed in a header. The callback receives a [response](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_serverresponse) that subscribes to the `data` event to aggregate the JSON body, the `error` event to log any issues, and the `end` event to know when the message should be considered complete. When complete, the app prints the interesting headers and message body. You can adjust the colors and set the depth to suit your preference. A depth of `1` gives a nice summary of the response.
57+
1. For the value of `hostname`, 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.
58+
59+
2. Use `encodeURIComponent` to escape invalid characters. The subscription key is passed in a header.
60+
61+
3. The callback receives a [response](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_serverresponse) that subscribes to the `data` event to aggregate the JSON body, the `error` event to log any issues, and the `end` event to know when the message should be considered complete.
62+
63+
4. When the app is complete, it prints the interesting headers and message body. You can adjust the colors and set the depth to suit your preference. A depth of `1` gives a nice summary of the response.
5864

5965
```javascript
6066
function bingWebSearch(query) {
@@ -100,7 +106,7 @@ bingWebSearch(query)
100106

101107
## Put it all together
102108

103-
The last step is to run your code: `node search.js "<your query>"`.
109+
The last step is to run your code with the command: `node search.js "<your query>"`.
104110

105111
If you'd like to compare your code with ours, here's the complete program:
106112

@@ -266,6 +272,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
266272
## Next steps
267273

268274
> [!div class="nextstepaction"]
269-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
275+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
270276
271277
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ms.custom: seodec2018
1616

1717
# Quickstart: Use PHP to call the Bing Web Search API
1818

19-
Use this quickstart to make your first call to the Bing Web Search API and receive the JSON response. This Node.js application sends a search request to the API, and shows the response. While this application is written in JavaScript, 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 Node.js application sends a search request to the API, and shows the JSON response. Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
2020

2121
## Prerequisites
2222

@@ -37,9 +37,13 @@ Before we get started, locate `php.ini` and uncomment this line:
3737

3838
## Create a project and define variables
3939

40-
Create a new PHP project in your favorite IDE or editor. Don't forget to add opening and closing tags `<?php` and `?>`.
40+
1. Create a new PHP project in your favorite IDE or editor. Add opening and closing tags: `<?php` and `?>`.
4141

42-
A few variables must be set before we can continue. `$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 `$accesskey` value with a valid subscription key from your Azure account. Feel free to customize the search query by replacing the value for `$term`.
42+
2. For the value of `$endpoint`, 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.
43+
44+
3. Confirm that the `$endpoint` value is correct and replace the `$accesskey` value with a valid subscription key from your Azure account.
45+
46+
4. Optionally, customize the search query by replacing the value for `$term`.
4347

4448
```php
4549
$accessKey = 'enter key here';
@@ -49,7 +53,7 @@ $term = 'Microsoft Cognitive Services';
4953

5054
## Construct a request
5155

52-
This code declares a function called `BingWebSearch` that is used to construct requests to the Bing Web Search API. It takes three arguments: `$url`, `$key`, and `$query`.
56+
This code declares a function called `BingWebSearch` that's used to construct requests to the Bing Web Search API. It takes three arguments: `$url`, `$key`, and `$query`.
5357

5458
```php
5559
function BingWebSearch ($url, $key, $query) {
@@ -109,7 +113,7 @@ if (strlen($accessKey) == 32) {
109113

110114
## Put it all together
111115

112-
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:
116+
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:
113117

114118
```php
115119
<?php
@@ -280,6 +284,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
280284
## Next steps
281285

282286
> [!div class="nextstepaction"]
283-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
287+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
284288
285289
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ To run this code locally, see the complete [sample available on GitHub](https://
8787
## Next steps
8888

8989
> [!div class="nextstepaction"]
90-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
90+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
9191
9292
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ require 'json'
3939

4040
## Define variables
4141

42-
A few variables must be set before we can continue. You can use the value of `uri` in the following code for the global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource. Confirm that `uri` and `path` are 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 `term`.
42+
A few variables must be set before we can continue:
43+
44+
1. For the value of `uri`, 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.
45+
46+
2. Confirm that the `uri` and `path` values are valid and replace the `accessKey` value with a subscription key from your Azure account.
47+
48+
3. Optionally, customize the search query by replacing the value for `term`.
4349

4450
```ruby
4551
accessKey = "YOUR_SUBSCRIPTION_KEY"
@@ -260,6 +266,6 @@ Responses from the Bing Web Search API are returned as JSON. This sample respons
260266
## Next steps
261267

262268
> [!div class="nextstepaction"]
263-
> [Bing Web search single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
269+
> [Bing Web Search API single-page app tutorial](../tutorial-bing-web-search-single-page-app.md)
264270
265271
[!INCLUDE [bing-web-search-quickstart-see-also](../../../../includes/bing-web-search-quickstart-see-also.md)]

includes/bing-web-search-quickstart-see-also.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ author: erikhopf
33
ms.author: erhopf
44
ms.service: cognitiveservices
55
ms.topic: include
6-
ms.date: 08/16/2018
6+
ms.date: 05/20/2020
77
---
88
## See also
99

10-
* [Bing Web Search API overview](../articles/cognitive-services/Bing-Web-Search/overview.md)
10+
* [What is the Bing Web Search API?](../articles/cognitive-services/Bing-Web-Search/overview.md)
1111
* [Bing Web Search API v7 reference](https://docs.microsoft.com/rest/api/cognitiveservices/bing-web-api-v7-reference)

0 commit comments

Comments
 (0)