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-News-Search/csharp.md
+32-27Lines changed: 32 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,30 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: bing-news-search
10
10
ms.topic: quickstart
11
-
ms.date: 12/12/2019
11
+
ms.date: 05/22/2020
12
12
ms.author: aahi
13
13
ms.custom: seodec2018
14
14
---
15
15
16
16
# Quickstart: Search for news using C# and the Bing News Search REST API
17
17
18
-
Use this quickstart to make your first call to the Bing News Search API and view the JSON response. This simple C# application sends a news search query to the API, and displays the response. The full code to this sample can be found on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingNewsSearchv7.cs).
18
+
Use this quickstart to make your first call to the Bing News Search API. This simple C# application sends a news search query to the API, and displays the JSON response.
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
+
22
+
The full code to this sample can be found on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingNewsSearchv7.cs).
21
23
22
24
## Prerequisites
23
25
24
26
* Any edition of [Visual Studio 2017 or later](https://www.visualstudio.com/downloads/).
25
27
* The [Json.NET](https://www.newtonsoft.com/json) framework, available as a NuGet package.
26
-
* If you are using Linux/MacOS, this application can be run using [Mono](https://www.mono-project.com/).
28
+
* If you're using Linux/MacOS, you can run this application 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.
34
+
1.Create a new C# console solution in Visual Studio. Then, add the following namespaces to the main code file:
33
35
34
36
```csharp
35
37
usingSystem;
@@ -39,30 +41,33 @@ While this application is written in C#, the API is a RESTful Web service compat
39
41
usingSystem.Collections.Generic;
40
42
```
41
43
42
-
2. Createvariablesfor the API endpoint, your subscription key, and search term. You can use the global endpoint below, or the [custom subdomain](../../cognitive-services/cognitive-services-custom-subdomains.md) endpointdisplayedintheAzureportalfor your resource.
44
+
2. Createvariablesfor the API endpoint, your subscription key, and search term. You can use the global endpoint in the following code, or use the [custom subdomain](../../cognitive-services/cognitive-services-custom-subdomains.md) endpointdisplayedintheAzureportalfor your resource.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-News-Search/go.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-visual-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/16/2019
12
+
ms.date: 05/22/2020
13
13
ms.author: aahi
14
14
---
15
15
@@ -18,15 +18,14 @@ ms.author: aahi
18
18
This quickstart uses the Go language to call the Bing News Search API. The results include names and URLs of news sources identified by the query string.
19
19
20
20
## Prerequisites
21
-
* Install the [Go binaries](https://golang.org/dl/)
22
-
* Install the go-spew library for it pretty printer to display results
23
-
* Install this library: `$ go get -u https://github.com/davecgh/go-spew`
21
+
* Install the [Go binaries](https://golang.org/dl/).
22
+
* Install the go-spew library to use a deep pretty printer to display the results. Use this command to install the library: `$ go get -u https://github.com/davecgh/go-spew`.
Create a new Go project in your IDE or editor. Then import `net/http` for requests, `ioutil` to read the response, and `encoding/json` to handle the JSON text of results. The go-spew library is needed to parse JSON.
28
+
Create a new Go project in your IDE or editor. Then, import `net/http` for requests, `ioutil` to read the response, `encoding/json` to handle the JSON text of results, and the `go-spew` library to parse the JSON results.
30
29
31
30
```go
32
31
package main
@@ -41,9 +40,9 @@ import (
41
40
42
41
```
43
42
44
-
## Create a struct to format the News search results
43
+
## Create a struct to format the news search results
45
44
46
-
The `NewsAnswer` struct formats the data provided in the response. The response JSONis multilevel and quite complex. The following implementation covers the essentials.
45
+
The `NewsAnswer` struct formats the data provided in the responseJSON, which is multilevel and complex. The following implementation covers the essentials:
47
46
48
47
```go
49
48
// This struct formats the answer provided by the Bing News Search API.
@@ -83,7 +82,7 @@ type NewsAnswer struct {
83
82
84
83
## Declare the main function and define variables
85
84
86
-
The following code declares the main function and assigns required variables. Confirm that the endpoint is correct and replace the `token` value with a valid subscription key from your Azure account. 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.
85
+
The following code declares the main function and assigns the required variables. Confirm that the endpoint is correct, and then replace the `token` value with a valid subscription key from your Azure account. 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.
Send the request and read the results by using `ioutil`.
139
138
140
139
```go
141
140
resp, err:= client.Do(req)
@@ -156,7 +155,7 @@ if err != nil {
156
155
157
156
## Handle the response
158
157
159
-
The `Unmarshall` function extracts information from the JSON text returned by the News Search API. Then you can display nodes from the results using the `go-spew` pretty printer.
158
+
The `Unmarshall` function extracts information from the JSON text returned by the Bing News Search API. Then, display nodes from the results with the `go-spew` pretty printer.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-News-Search/java.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,31 +9,30 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-news-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/16/2019
12
+
ms.date: 05/22/2020
13
13
ms.author: aahi
14
14
ms.custom: seodec2018
15
15
---
16
16
17
17
# Quickstart: Perform a news search using Java and the Bing News Search REST API
18
18
19
-
Use this quickstart to make your first call to the Bing News Search API and view the JSON response. This simple Java application sends a news search query to the API, and displays the response.
19
+
Use this quickstart to make your first call to the Bing News Search API. This simple Java application sends a news search query to the API, and displays the JSON response.
20
20
21
-
While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
21
+
Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
22
22
23
-
The source code for this sample is available [on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingNewsSearchv7.java)
23
+
The source code for this sample is available [on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingNewsSearchv7.java).
24
24
25
25
## Prerequisites
26
26
27
-
* The [Java Development Kit(JDK) 7 or 8](https://aka.ms/azure-jdks)
28
-
29
-
* The [Gson library](https://github.com/google/gson)
27
+
* The [Java Development Kit (JDK) 7 or 8](https://aka.ms/azure-jdks).
28
+
* 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.
35
+
1. Create a new Java project in your favorite IDE or editor, and import the following libraries:
37
36
38
37
```java
39
38
importjava.net.*;
@@ -46,7 +45,7 @@ The source code for this sample is available [on GitHub](https://github.com/Azur
46
45
importcom.google.gson.JsonParser;
47
46
```
48
47
49
-
2.Create a new class, with variables for the API endpoint, your subscription key, and search term. 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.Create a new class. Add variables for the API endpoint, your subscription key, and search term. 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.
@@ -60,7 +59,7 @@ The source code for this sample is available [on GitHub](https://github.com/Azur
60
59
61
60
## Construct the search request, and receive a JSON response
62
61
63
-
1.Use the variables from the last step to format a search URLfor the API request. Note that your search term must be URL-encoded before being appended to the request.
62
+
1.Use the variables from the previous step to format a search URLfor the API request. URL-encode your search term before you append it to the request.
0 commit comments