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-Video-Search/quickstarts/csharp.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,26 +9,26 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-video-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/09/2019
12
+
ms.date: 05/19/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Search for videos using the Bing Video Search REST API and C#
17
17
18
-
Use this quickstart to make your first call to the Bing Video Search API and view a search result from the JSON response. This simple C# application sends an HTTP video search query to the API, and displays the response. While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
18
+
Use this quickstart to make your first call to the Bing Video Search API. This simple C# application sends an HTTP video search query to the API, and displays the JSON response. Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
19
19
20
20
The source code for this sample is available [on GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingVideoSearchv7.cs) with additional error handling, features, and code annotations.
21
21
22
22
## Prerequisites
23
23
* Any edition of [Visual Studio 2017 or later](https://www.visualstudio.com/downloads/).
24
24
* The [Json.NET](https://www.newtonsoft.com/json) framework, available as a NuGet package.
25
-
* If you are using Linux/MacOS, this application can be run using [Mono](https://www.mono-project.com/).
25
+
* If you're using Linux/MacOS, this application can be run using [Mono](https://www.mono-project.com/).
1. Create a new console solution in Visual Studio. Then add the following namespaces into the main code file.
31
+
1. Create a new console solution in Visual Studio. Then, add the following namespaces to the main code file:
32
32
33
33
```csharp
34
34
usingSystem;
@@ -38,17 +38,17 @@ The source code for this sample is available [on GitHub](https://github.com/Azur
38
38
usingSystem.Collections.Generic;
39
39
```
40
40
41
-
2. Addvariablesfor your subscription key, endpoint, and search term. `uriBase` can be the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpointdisplayedintheAzureportalfor your resource.
41
+
2. Addvariablesfor your subscription key, endpoint, and search term. 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) endpointdisplayedintheAzureportalfor your resource.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Video-Search/quickstarts/java.md
+43-41Lines changed: 43 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,16 +9,18 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-video-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/09/2019
12
+
ms.date: 05/19/2020
13
13
ms.author: aahi
14
14
---
15
15
# Quickstart: Search for videos using the Bing Video Search REST API and Java
16
16
17
-
Use this quickstart to make your first call to the Bing Video Search API and view a search result from the JSON response. This simple Java application sends an HTTP video search query to the API, and displays the response. While this application is written in Java, 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/java/Search/BingVideoSearchv7.java) with additional error handling, features, and code annotations.
17
+
Use this quickstart to make your first call to the Bing Video Search API. This simple Java application sends an HTTP video search query to the API and displays the JSON response.
18
+
19
+
Although this application is written in Java, 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/java/Search/BingVideoSearchv7.java) with additional error handling, features, and code annotations.
18
20
19
21
## Prerequisites
20
22
21
-
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html)
23
+
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html)
22
24
23
25
* The [Gson library](https://github.com/google/gson)
24
26
@@ -27,7 +29,7 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
27
29
28
30
## Create and initialize a project
29
31
30
-
1. Create a new Java project in your favorite IDE or editor, and import the following libraries.
32
+
1. Create a new Java project in your favorite IDE or editor, and import the following libraries:
31
33
32
34
```java
33
35
importjava.net.*;
@@ -54,7 +56,7 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
54
56
}
55
57
```
56
58
57
-
3.Create a new method named `SearchVideos()` with variables for your API endpoint host and path, your subscription key, and a search term. It will return a `SearchResults` object. `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.
59
+
3.Create a new method named `SearchVideos()` with variables for your API endpoint host and path, your subscription key, and search term. This method returns a `SearchResults` object. You can use the value of `host` in the following code forthe global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
@@ -67,41 +69,41 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
67
69
68
70
## Construct and send the search request
69
71
70
-
1.In `SearchVideos()`, perform the following steps:
72
+
Inthe `SearchVideos()` method, perform the following steps:
71
73
72
-
1.construct the URLfor your request by combining your API host, path, and encoding your search query. Then use `openConnection()` to create a connection, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
74
+
1.Construct the URLfor your request by combining your API host, path, and encoded search query. Then, use `openConnection()` to create a connection, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
3.Use `getHeaderFields();` to extract the HTTP headers from the response, and store the Bing-related ones in the `results` object. Then close the stream and return the result.
89
+
3.Use `getHeaderFields()` to extract the HTTP headers from the response, and store the Bing-related ones in the `results` object. Then, close the stream and return the result.
1.Create a method named `prettify()` to format the response returned from the BingVideoAPI. Use the Gson library's `JsonParser` to take in a JSON string and convert it into an object. Then use `GsonBuilder()` and `toJson()` to create the formatted string.
106
+
1.Create a method named `prettify()` to format the response returned from the BingVideoAPI. Use the Gson library's `JsonParser` to convert a JSON string to an object. Then, use `GsonBuilder()` and `toJson()` to create the formatted string.
105
107
106
108
```java
107
109
// pretty-printer for JSON; uses GSON parser to parse and re-serialize
@@ -115,18 +117,18 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
115
117
116
118
## Send the request and print the response
117
119
118
-
1. In the main method of your application, call `SearchVideos` with your search term. you can then print the HTTP headers stored in the response, as well as the JSON string returned by the API.
120
+
In the main method of your application, call `SearchVideos` with your search term. Then, print the HTTP headers stored in the response and the JSON string returned by the API.
119
121
120
-
```java
121
-
public static void main (String[] args) {
122
+
```java
123
+
public static void main (String[] args) {
122
124
123
-
SearchResults result = SearchVideos(searchTerm);
124
-
//print the Relevant HTTP Headers
125
-
for (String header : result.relevantHeaders.keySet())
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Video-Search/quickstarts/nodejs.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,19 +9,20 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-video-search
11
11
ms.topic: quickstart
12
-
ms.date: 12/09/2019
12
+
ms.date: 05/19/2020
13
13
ms.author: aahi
14
14
---
15
15
# Quickstart: Search for videos using the Bing Video Search REST API and Node.js
16
16
17
-
Use this quickstart to make your first call to the Bing Video Search API and view a search result from the JSON response. This simple JavaScript application sends an HTTP video search query to the API, and displays the response. While this application is written in JavaScript and uses Node.js, 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/nodejs/Search/BingVideoSearchv7.js) with additional error handling, and code annotations.
17
+
Use this quickstart to make your first call to the Bing Video Search API. This simple JavaScript application sends an HTTP video search query to the API, and displays the JSON response.
18
+
19
+
Although this application is written in JavaScript and uses Node.js, 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/nodejs/Search/BingVideoSearchv7.js) with additional error handling, and code annotations.
18
20
19
21
## Prerequisites
20
22
21
-
*[Node.js](https://nodejs.org/en/download/)
23
+
*[Node.js](https://nodejs.org/en/download/).
22
24
23
-
* The Request module for JavaScript
24
-
* You can install this module using `npm install request`
25
+
* The Request module for JavaScript. Install this module by using `npm install request`.
@@ -34,7 +35,7 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
34
35
let https =require('https');
35
36
```
36
37
37
-
2. Create variables for your API endpoint, subscription key, and your search term. `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.
38
+
2. Create variables for your API endpoint, subscription key, and search term. You can use the value of`host`in the following code forthe global endpoint, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
38
39
39
40
```javascript
40
41
let subscriptionKey = 'enter key here';
@@ -45,7 +46,7 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
45
46
46
47
## Create a response handler
47
48
48
-
1. Create a function called `response_handler` to take a JSON response from the API. Create a variable for the response body. Append the response when a `data` flag is received, using `response.on()`.
49
+
1. Create a function called `response_handler` to take a JSON response from the API. Create a variable for the response body. Append the response when a `data` flag is received by using `response.on()`.
49
50
50
51
```javascript
51
52
let response_handler = function (response) {
@@ -56,23 +57,23 @@ Use this quickstart to make your first call to the Bing Video Search API and vie
56
57
};
57
58
```
58
59
59
-
1. When `end` is signaled, use `response.on()` to store the bing-related headers (beginning with`bingapis` or `x-msedge-`). Then parse the JSON using `JSON.parse()`, convert it to a string with`JSON.stringify()`, and print it.
60
-
61
-
```javascript
62
-
response.on('end', function () {
63
-
for (var header in response.headers)
64
-
// header keys are lower-cased by Node.js
65
-
if (header.startsWith("bingapis-") || header.startsWith("x-msedge-"))
body = JSON.stringify(JSON.parse(body), null, ' ');
68
-
//JSON Response body
69
-
console.log(body);
70
-
});
71
-
```
60
+
1. When `end` is signaled, use `response.on()` to store the bing-related headers (beginning with`bingapis` or `x-msedge-`). Parse the JSON using `JSON.parse()`, convert it to a string with`JSON.stringify()`, and print it.
61
+
62
+
```javascript
63
+
response.on('end', function () {
64
+
for (var header in response.headers)
65
+
// header keys are lower-cased by Node.js
66
+
if (header.startsWith("bingapis-") || header.startsWith("x-msedge-"))
body = JSON.stringify(JSON.parse(body), null, ' ');
69
+
//JSON Response body
70
+
console.log(body);
71
+
});
72
+
```
72
73
73
74
## Create and send the search request
74
75
75
-
1.Create a function called `bing_video_search()`. Add the parameters for your request including your host name, and headers. Encode your search term and append it to your path parameter with the `?q=` parameter. Then send the request with `req.end()`.
76
+
Create a function called `bing_video_search()`. Add the parameters for your request including your host name, and headers. Encode your search term and append it to your path parameter with the `?q=` parameter. Then, send the request with `req.end()`.
0 commit comments