Skip to content

Commit b7b0e39

Browse files
author
dksimpson
committed
Edits
1 parent 32d8abf commit b7b0e39

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

articles/cognitive-services/Bing-News-Search/csharp.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -61,44 +61,44 @@ struct SearchResult
6161

6262
## Create and handle a news search request
6363

64-
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:
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:
6565

66-
1. Construct the URI for the search request. The `toSearch` search term must be formatted before it's appended to the string.
66+
1. Construct the URI for the search request. The `toSearch` search term must be formatted before it's appended to the string.
6767

68-
```csharp
69-
static SearchResult BingNewsSearch(string toSearch){
68+
```csharp
69+
static SearchResult BingNewsSearch(string toSearch){
7070

71-
var uriQuery = uriBase + "?q=" + Uri.EscapeDataString(toSearch);
72-
//...
73-
```
71+
var uriQuery = uriBase + "?q=" + Uri.EscapeDataString(toSearch);
72+
//...
73+
```
7474

75-
2. Perform the web request and get the response as a JSON string.
75+
1. Perform the web request and get the response as a JSON string.
7676

77-
```csharp
78-
WebRequest request = WebRequest.Create(uriQuery);
79-
request.Headers["Ocp-Apim-Subscription-Key"] = subscriptionKey;
80-
HttpWebResponse response = (HttpWebResponse)request.GetResponseAsync().Result;
81-
string json = new StreamReader(response.GetResponseStream()).ReadToEnd();
82-
```
77+
```csharp
78+
WebRequest request = WebRequest.Create(uriQuery);
79+
request.Headers["Ocp-Apim-Subscription-Key"] = subscriptionKey;
80+
HttpWebResponse response = (HttpWebResponse)request.GetResponseAsync().Result;
81+
string json = new StreamReader(response.GetResponseStream()).ReadToEnd();
82+
```
8383

84-
3. Create the search result object, and extract the Bing HTTP headers. Then, return `searchResult`.
84+
1. Create the search result object, and extract the Bing HTTP headers. Then, return `searchResult`.
8585

86-
```csharp
87-
// Create the result object for return
88-
var searchResult = new SearchResult()
89-
{
90-
jsonResult = json,
91-
relevantHeaders = new Dictionary<String, String>()
92-
};
93-
94-
// Extract Bing HTTP headers
95-
foreach (String header in response.Headers)
96-
{
97-
if (header.StartsWith("BingAPIs-") || header.StartsWith("X-MSEdge-"))
98-
searchResult.relevantHeaders[header] = response.Headers[header];
99-
}
100-
return searchResult;
101-
```
86+
```csharp
87+
// Create the result object for return
88+
var searchResult = new SearchResult()
89+
{
90+
jsonResult = json,
91+
relevantHeaders = new Dictionary<String, String>()
92+
};
93+
94+
// Extract Bing HTTP headers
95+
foreach (String header in response.Headers)
96+
{
97+
if (header.StartsWith("BingAPIs-") || header.StartsWith("X-MSEdge-"))
98+
searchResult.relevantHeaders[header] = response.Headers[header];
99+
}
100+
return searchResult;
101+
```
102102

103103
## Process the response
104104

@@ -111,7 +111,7 @@ In the main method, call `BingNewsSearch()` and store the returned response. The
111111
Console.WriteLine(jsonObj["value"][0])
112112
```
113113

114-
## JSON Response
114+
## Example JSON response
115115

116116
A successful response is returned in JSON, as shown in the following example:
117117

articles/cognitive-services/Bing-News-Search/java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ The source code for this sample is available [on GitHub](https://github.com/Azur
124124
}
125125
```
126126

127-
## JSON Response
127+
## Example JSON response
128128

129129
A successful response is returned in JSON, as shown in the following example:
130130

articles/cognitive-services/Bing-News-Search/nodejs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ The source code for this sample is available on [GitHub](https://github.com/Azur
8080
});
8181
```
8282

83-
## JSON Response
83+
## Example JSON response
8484

8585
A successful response is returned in JSON, as shown in the following example:
8686

articles/cognitive-services/Bing-News-Search/php.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ echo json_encode(json_decode($json), JSON_PRETTY_PRINT);
9898
?>
9999
```
100100

101-
**Response**
101+
## Example JSON response
102102

103103
A successful response is returned in JSON, as shown in the following example:
104104

articles/cognitive-services/Bing-News-Search/python.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ search_url = "https://api.cognitive.microsoft.com/bing/v7.0/news/search"
4242

4343
## Create parameters for the request
4444

45-
Add your subscription key to a new dictionary, using `"Ocp-Apim-Subscription-Key"` as the key. Do the same for your search parameters.
45+
Add your subscription key to a new dictionary, using `Ocp-Apim-Subscription-Key` as the key. Do the same for your search parameters.
4646

4747
```python
4848
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
@@ -67,7 +67,7 @@ params = {"q": search_term, "textDecorations": True, "textFormat": "HTML"}
6767

6868
## Display the results
6969

70-
These descriptions can then be rendered as a table with the search keyword highlighted in **bold**.
70+
These descriptions can then be rendered as a table with the search keyword highlighted in bold.
7171

7272
```python
7373
from IPython.display import HTML

articles/cognitive-services/Bing-News-Search/ruby.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ puts "\nJSON Response:\n\n"
7474
puts JSON::pretty_generate(JSON(response.body))
7575
```
7676

77-
## JSON Response
77+
## Example JSON response
7878

7979
A successful response is returned in JSON, as shown in the following example:
8080

0 commit comments

Comments
 (0)