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
+36-32Lines changed: 36 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,12 @@ ms.custom: seodec2018
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. This simple C# application sends a news search query to the API, and displays the JSON 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
20
Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
21
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).
23
+
22
24
## Prerequisites
23
25
24
26
* Any edition of [Visual Studio 2017 or later](https://www.visualstudio.com/downloads/).
@@ -29,7 +31,7 @@ Although this application is written in C#, the API is a RESTful Web service com
29
31
30
32
## Create and initialize a project
31
33
32
-
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;
@@ -61,44 +63,46 @@ struct SearchResult
61
63
62
64
## Create and handle a news search request
63
65
64
-
1. Create a method named `BingNewsSearch()` to perform the call to the API, and set the return type to the `SearchResult` struct created previously. In the method, do the following steps:
66
+
1. Create a method named `BingNewsSearch()` to perform the call to the API, and set the return type to the `SearchResult` struct created previously.
65
67
66
-
1. Construct the URI for the search request. The `toSearch` search term must be formatted before it's appended to the string.
68
+
Add code to this method in the steps that follow.
67
69
68
-
```csharp
69
-
staticSearchResultBingNewsSearch(stringtoSearch){
70
+
1. Construct the URI for the search request. The `toSearch` search term must be formatted before it's appended to the string.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-News-Search/go.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +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 to use a deep pretty printer to display results. Use this command to install the 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.
29
29
30
30
```go
31
31
package main
@@ -40,7 +40,7 @@ import (
40
40
41
41
```
42
42
43
-
## Create a struct to format the News search results
43
+
## Create a struct to format the news search results
44
44
45
45
The `NewsAnswer` struct formats the data provided in the response JSON, which is multilevel and complex. The following implementation covers the essentials:
46
46
@@ -82,7 +82,7 @@ type NewsAnswer struct {
82
82
83
83
## Declare the main function and define variables
84
84
85
-
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 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.
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.
86
86
87
87
```go
88
88
funcmain() {
@@ -134,7 +134,7 @@ if err != nil {
134
134
135
135
## Send the request
136
136
137
-
Send the request and read results by using `ioutil`.
137
+
Send the request and read the results by using `ioutil`.
138
138
139
139
```go
140
140
resp, err:= client.Do(req)
@@ -155,7 +155,7 @@ if err != nil {
155
155
156
156
## Handle the response
157
157
158
-
The `Unmarshall` function extracts information from the JSON text returned by the News Search API. Then, you can display nodes from the results by 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/php.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,12 +31,12 @@ For more information, see [Cognitive Services Pricing - Bing Search API](https:/
31
31
32
32
To run this application, follow these steps:
33
33
34
-
1.Make sure that secure HTTP support is enabled in your `php.ini` file, as described in the code comment.
34
+
1.Enable secure HTTP support in your `php.ini` file by uncommenting the `;extension=php_openssl.dll` line, as described in the code comment.
35
35
2. Create a new PHP project in your favorite IDE or editor.
36
36
3. Add the code provided below.
37
37
4. Replace the `accessKey` value with an access key valid for your subscription.
38
38
5. 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.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-News-Search/ruby.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,9 @@ ms.custom: seodec2018
18
18
19
19
Use this quickstart to make your first call to the Bing News Search API. This simple Ruby application sends a search query to the API and processes the JSON response.
20
20
21
-
Although this application is written in Ruby, the API is a RESTful Web service compatible with most programming languages. The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/ruby/Search/BingNewsSearchv7.rb).
21
+
Although this application is written in Ruby, the API is a RESTful Web service compatible with most programming languages.
22
+
23
+
The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/ruby/Search/BingNewsSearchv7.rb).
22
24
23
25
## Prerequisites
24
26
@@ -47,7 +49,7 @@ Although this application is written in Ruby, the API is a RESTful Web service c
47
49
48
50
## Format and make an API request
49
51
50
-
Use the variables from the last step to format a search URLfor the API request. Then, send the request.
52
+
Use the variables from the previous step to format a search URLfor the API request. Then, send the request.
51
53
52
54
```ruby
53
55
uri = URI(uri + path + "?q=" + URI.escape(term))
@@ -60,7 +62,7 @@ end
60
62
61
63
## Process and print the JSON response
62
64
63
-
After the response is received, you can parse the JSON, andprint both the response body,and its headers.
65
+
After the response is received, parse the JSON, andthenprint both the response body and its headers.
0 commit comments