Video Search API - v7
The Video API lets partners send a search query to Bing and get back a list of relevant videos. Note you should call the Video API if you need video content only. If you need other content such as news and webpages in addition to videos, you must call the Search API which includes videos in the response. You must display the videos in the order provided in the response.
Trending
Get currently trending videos.
Select the testing console in the region where you created your resource:
Global West US West US 2 East US East US 2 West Central US South Central US West Europe North Europe Southeast Asia East Asia Australia East Brazil South Canada Central Central India UK South Japan East Central US France Central Korea Central Japan West North Central US South Africa NorthRequest URL
Request headers
string
Subscription key which provides access to this API. Found in your Cognitive Services accounts.
Request body
Response 200
{
"_type": "TrendingVideos",
"instrumentation": {
"pingUrlBase": "https://www.bingapis.com/api/ping?IG=9AA1B29CDDE742C18DB8A9B443C1DB56&CID=070910FF0C0362112C11188E0DD06323&ID=",
"pageLoadPingUrl": "https://www.bingapis.com/api/ping/pageload"
},
"bannerTiles": [
{
"query": {
"text": "Country Nation - Brad Paisley",
"displayText": "Country Nation - Brad Paisley",
"webSearchUrl": "https://www.bing.com/videos/search?q=Country%20Nation%20-%20Brad%20Paisley&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7424.1"
},
"image": {
"description": "Image from: nashvillekat.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M9c482cb00d98074e074d6b6f802406d0o1&pid=Api",
"headLine": "\"Country Nation\" is a song recorded by American country music artist Brad Paisley. It was released on September 14, 2015 by Arista Nashville as the fourth single from his tenth studio album, Moonshine in the Trunk.",
"contentUrl": "http://2.bp.blogspot.com/-UZiUlrQCYPw/UYzdwhUNf1I/AAAAAAAAHlM/aFyY7cVNPys/s1600/brad-paisley2.jpg"
}
},
{
"query": {
"text": "Panda Bear's Adorable Reaction To Snow",
"displayText": "Panda Bear's Adorable Reaction To Snow",
"webSearchUrl": "https://www.bing.com/videos/search?q=Panda%20Bear's%20Adorable%20Reaction%20To%20Snow&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7428.1"
},
"image": {
"description": "Image from: lebanontimes.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.M810b3f6695f27a55cb0034f713346eb1H0&pid=Api",
"headLine": "Tian Tian, one of the giant pandas at Smithsonian's National Zoo, woke up to snow and was pretty excited about it.",
"contentUrl": "http://www.lebanontimes.com/wp-content/uploads/2012/12/2dc3c2ae825_634x399.jpg"
}
}
],
"categories": [
{
"title": "Music videos",
"subcategories": [
{
"tiles": [
{
"query": {
"text": "Hello - Adele",
"displayText": "Hello - Adele",
"webSearchUrl": "https://www.bing.com/videos/search?q=Hello%20-%20Adele&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7436.1"
},
"image": {
"description": "Image from: beautyfrontline.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.Md36fe1c5fcc52da3d146106c9850aea2o0&pid=Api",
"contentUrl": "http://1.bp.blogspot.com/-dPdrQYg-X-M/UG97BFb3DYI/AAAAAAAAAQI/KJ9DyNOaWio/s640/ADELE-VOGUE-PHOTOSHOOT.png"
}
},
{
"query": {
"text": "Hotline Bling - Drake",
"displayText": "Hotline Bling - Drake",
"webSearchUrl": "https://www.bing.com/videos/search?q=Hotline%20Bling%20-%20Drake&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7438.1"
},
"image": {
"description": "Image from: hollywoodreporter.com",
"thumbnailUrl": "https://tse3.mm.bing.net/th?id=OIP.M301f6741e9ae38a00dbf6d0088b631c1o2&pid=Api",
"contentUrl": "http://cdn2.thr.com/sites/default/files/imagecache/thr_style_news_image/2015/07/drake_2015_wimbledon_h_15.jpg"
}
}
],
"title": "Top "
},
{
"tiles": [
{
"query": {
"text": "Same Old Love - Selena Gomez",
"displayText": "Same Old Love - Selena Gomez",
"webSearchUrl": "https://www.bing.com/videos/search?q=Same%20Old%20Love%20-%20Selena%20Gomez&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7452.1"
},
"image": {
"description": "Image from: vegasseven.com",
"thumbnailUrl": "https://tse4.mm.bing.net/th?id=OIP.M7b94b12412e1b6e30ca155e932ab6fe2H0&pid=Api",
"contentUrl": "http://vegasseven.com/files/2013/11/selena-gomez-singing-wallpaper-3734.jpg"
}
},
{
"query": {
"text": "Out Of The Woods - Taylor Swift",
"displayText": "Out Of The Woods - Taylor Swift",
"webSearchUrl": "https://www.bing.com/videos/search?q=Out%20Of%20The%20Woods%20-%20Taylor%20Swift&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7454.1"
},
"image": {
"description": "Image from: glamorhairstyles.com",
"thumbnailUrl": "https://tse3.mm.bing.net/th?id=OIP.M187bd46210527fe4b4a655be7e063a8bo2&pid=Api",
"contentUrl": "http://www.glamorhairstyles.com/wp-content/uploads/2015/05/Taylor-Swift-Hairstyles-2015-6.jpg"
}
}
],
"title": "Trending"
},
{
"tiles": [
{
"query": {
"text": "Love Yourself - Justin Bieber",
"displayText": "Love Yourself - Justin Bieber",
"webSearchUrl": "https://www.bing.com/videos/search?q=Love%20Yourself%20-%20Justin%20Bieber&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7468.1"
},
"image": {
"description": "Image from: abitofpopmusic.com",
"thumbnailUrl": "https://tse3.mm.bing.net/th?id=OIP.M4e5d8f27e360982c5e461db28667a7e2o2&pid=Api",
"contentUrl": "https://abitofpopmusic.files.wordpress.com/2015/09/justin-bieber-what-do-you-mean.png"
}
},
{
"query": {
"text": "Don't - Bryson Tiller",
"displayText": "Don't - Bryson Tiller",
"webSearchUrl": "https://www.bing.com/videos/search?q=Don't%20-%20Bryson%20Tiller&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7470.1"
},
"image": {
"description": "Image from: genius.com",
"thumbnailUrl": "https://tse4.mm.bing.net/th?id=OIP.M8f45ddabae61d342769af2a32a8751e9o0&pid=Api",
"contentUrl": "http://images.rapgenius.com/a0e91b5f06cdd8c7b3f1a87ad853a604.640x640x1.jpg"
}
}
],
"title": "More music videos"
}
]
},
{
"title": "Viral videos",
"subcategories": [
{
"tiles": [
{
"query": {
"text": "Russia's Arctic Troops Train With Reindeer",
"displayText": "Russia's Arctic Troops Train With Reindeer",
"webSearchUrl": "https://www.bing.com/videos/search?q=Russia's%20Arctic%20Troops%20Train%20With%20Reindeer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7478.1"
},
"image": {
"description": "Image from: arcticrussiatravel.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.Mc956d012aaef6bf4ec6bba03b9b85f3co0&pid=Api",
"contentUrl": "http://www.arcticrussiatravel.com/wp-content/uploads/2012/05/%D0%98%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5-531.jpg"
}
},
{
"query": {
"text": "A Woman Pulls Over A Cop For Speeding",
"displayText": "A Woman Pulls Over A Cop For Speeding",
"webSearchUrl": "https://www.bing.com/videos/search?q=A%20Woman%20Pulls%20Over%20A%20Cop%20For%20Speeding&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7480.1"
},
"image": {
"description": "Image from: photographyisnotacrime.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M01c52de0bdb4d38cc600d7347cf5d6a9o0&pid=Api",
"contentUrl": "https://photographyisnotacrime.com/wp-content/uploads/2016/01/Miami-Dade-police-officer.jpg"
}
}
],
"title": "This week"
},
{
"tiles": [
{
"query": {
"text": "Female Shark Devours Smaller Rival",
"displayText": "Female Shark Devours Smaller Rival",
"webSearchUrl": "https://www.bing.com/videos/search?q=Female%20Shark%20Devours%20Smaller%20Rival&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7494.1"
},
"image": {
"description": "Image from: newsfine.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.M58cd04532829899818cf23954c0f527fo0&pid=Api",
"contentUrl": "http://assets.nydailynews.com/polopoly_fs/1.1777675.1399071199!/img/httpImage/image.jpg_gen/derivatives/article_970/shark3n-1-web.jpg"
}
},
{
"query": {
"text": "Head-On Collision Created Earth's Moon",
"displayText": "Head-On Collision Created Earth's Moon",
"webSearchUrl": "https://www.bing.com/videos/search?q=Head-On%20Collision%20Created%20Earth's%20Moon&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7496.1"
},
"image": {
"description": "Image from: ircamera.as.arizona.edu",
"thumbnailUrl": "https://tse4.mm.bing.net/th?id=OIP.Me0f25cac8d5b540a373daf994654e5d8o0&pid=Api",
"contentUrl": "http://ircamera.as.arizona.edu/NatSci102/NatSci102/images/moon-formation.jpg"
}
}
],
"title": "Last week"
},
{
"tiles": [
{
"query": {
"text": "Curiosity's Selfie Amid Martian Dunes",
"displayText": "Curiosity's Selfie Amid Martian Dunes",
"webSearchUrl": "https://www.bing.com/videos/search?q=Curiosity's%20Selfie%20Amid%20Martian%20Dunes&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7510.1"
},
"image": {
"description": "Image from: news.yahoo.com",
"thumbnailUrl": "https://tse4.mm.bing.net/th?id=OIP.M97908257b701132e600cab70d2b37b1ao0&pid=Api",
"contentUrl": "http://l.yimg.com/bt/api/res/1.2/p0xCUBEYYIstY7F.y4QDag--/YXBwaWQ9eW5ld3NfbGVnbztxPTg1/http://media.zenfs.com/en-US/homerun/mashable_science_572/d0927cec2fe7574b563e244b4d813a9f"
}
},
{
"query": {
"text": "5 Optical Illusions Melt Your Mind",
"displayText": "5 Optical Illusions Melt Your Mind",
"webSearchUrl": "https://www.bing.com/videos/search?q=5%20Optical%20Illusions%20Melt%20Your%20Mind&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7512.1"
},
"image": {
"description": "Image from: playbuzz.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.M31356e70bb8a0b15f891d8ee6e31855ao0&pid=Api",
"contentUrl": "http://cdn.playbuzz.com/cdn/230f2af8-44a5-41b4-8bfa-0d361e94faef/a8434f11-71d0-4126-9044-de052824300a.gif"
}
}
],
"title": "More viral videos"
}
]
},
{
"title": "TV shows",
"subcategories": [
{
"tiles": [
{
"query": {
"text": "Arrow TV",
"displayText": "Arrow TV",
"webSearchUrl": "https://www.bing.com/videos/search?q=Arrow%20TV&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7520.1"
},
"image": {
"description": "Image from: moviepilot.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.M2646679bc56c242627789de67adac400o0&pid=Api",
"contentUrl": "http://images-cdn.moviepilot.com/image/upload/c_fill,h_900,w_1600/t_mp_quality/why-arrow-is-not-a-green-arrow-tv-show-arrow-season-3-poster-jpeg-249567.jpg"
}
},
{
"query": {
"text": "Criminal Minds",
"displayText": "Criminal Minds",
"webSearchUrl": "https://www.bing.com/videos/search?q=Criminal%20Minds&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7522.1"
},
"image": {
"description": "Image from: mcla.libguides.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.Mb487666983a4401ca0a2e6b26ba7340aH0&pid=Api",
"contentUrl": "http://haveuheard.net/wp-content/uploads/2013/04/Criminal-Minds-3.jpg"
}
}
],
"title": "Most watched"
},
{
"tiles": [
{
"query": {
"text": "The Mentalist",
"displayText": "The Mentalist",
"webSearchUrl": "https://www.bing.com/videos/search?q=The%20Mentalist&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7536.1"
},
"image": {
"description": "Image from: meilleurvpn.org",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M322d0946721d458b8e3f123eca8f7383H0&pid=Api",
"contentUrl": "http://meilleurvpn.org/wp-content/uploads/fichiers/2013/12/the-mentalist.jpg"
}
},
{
"query": {
"text": "Once Upon a Time",
"displayText": "Once Upon a Time",
"webSearchUrl": "https://www.bing.com/videos/search?q=Once%20Upon%20a%20Time&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7538.1"
},
"image": {
"description": "Image from: neverlandbitch.unblog.fr",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.Mb189f46ee41efce0f79b8a775f0c8f20H0&pid=Api",
"contentUrl": "http://www.wallpapersfolder.com/user-content/uploads/wall/o/64/once_upon_a_time_wallpaper.jpg"
}
}
],
"title": "Trending "
},
{
"tiles": [
{
"query": {
"text": "Coronation Street",
"displayText": "Coronation Street",
"webSearchUrl": "https://www.bing.com/videos/search?q=Coronation%20Street&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7552.1"
},
"image": {
"description": "Image from: coronationstreet.wikia.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.Mb36d93f596f74121258279547eaccc07H0&pid=Api",
"contentUrl": "http://images2.wikia.nocookie.net/__cb20111109230452/coronationstreet/images/a/a2/Coronation_street_title.jpg"
}
},
{
"query": {
"text": "Black Sails",
"displayText": "Black Sails",
"webSearchUrl": "https://www.bing.com/videos/search?q=Black%20Sails&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7554.1"
},
"image": {
"description": "Image from: themindreels.com",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M4d5de4ec99fe931211e3af41b10fdc75H1&pid=Api",
"contentUrl": "https://mindreels.files.wordpress.com/2015/01/black-sails.jpg"
}
}
],
"title": "More TV shows"
}
]
},
{
"title": "Movie trailers",
"subcategories": [
{
"tiles": [
{
"query": {
"text": "Saala Khadoos Trailer",
"displayText": "Saala Khadoos Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=Saala%20Khadoos%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7568.1"
},
"image": {
"description": "Image from: metromatinee.com",
"thumbnailUrl": "https://tse2.mm.bing.net/th?id=OIP.M714957bad256b2ebdda33c3d62e45956o0&pid=Api",
"contentUrl": "http://www.metromatinee.com/movies/images/m4983/thumb/saala-khadoos-70798.jpg"
}
},
{
"query": {
"text": "The Finest Hours (2016) Trailer",
"displayText": "The Finest Hours (2016) Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=The%20Finest%20Hours%20(2016)%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7570.1"
},
"image": {
"description": "Image from: tribute.ca",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M2547ab2f5405a0511dcdff9c63367a55o0&pid=Api",
"contentUrl": "http://www.tribute.ca/news/wp-content/uploads/2016/01/the-finest-hours-poster.jpg"
}
}
],
"title": "In theaters"
},
{
"tiles": [
{
"query": {
"text": "London Has Fallen Trailer",
"displayText": "London Has Fallen Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=London%20Has%20Fallen%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7584.1"
},
"image": {
"description": "Image from: klatsch-tratsch.de",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M4d2ce276c5c88cae522f26632eb1e14ao0&pid=Api",
"contentUrl": "http://www.klatsch-tratsch.de/wp-content/uploads/2015/11/LONDONFALLEN_1SHTO_BIGBEN_deutsch_A4.jpg"
}
},
{
"query": {
"text": "Triple 9 (2016) Trailer",
"displayText": "Triple 9 (2016) Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=Triple%209%20(2016)%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7586.1"
},
"image": {
"description": "Image from: movie-list.com",
"thumbnailUrl": "https://tse3.mm.bing.net/th?id=OIP.M3b2ac231aef49c1c24ed475c3718a456o0&pid=Api",
"contentUrl": "http://www.movie-list.com/img/posters/big/zoom/triple9.jpg"
}
}
],
"title": "Coming soon"
},
{
"tiles": [
{
"query": {
"text": "How To Be Single Trailer",
"displayText": "How To Be Single Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=How%20To%20Be%20Single%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7600.1"
},
"image": {
"description": "Image from: promicabana.de",
"thumbnailUrl": "https://tse1.mm.bing.net/th?id=OIP.M9ba9eff98fed1964b2b6d1fa89965da2o0&pid=Api",
"contentUrl": "http://www.promicabana.de/wp-content/uploads/2015/11/How-to-Be-Single-Poster.jpg"
}
},
{
"query": {
"text": "The Boy (2016) Trailer",
"displayText": "The Boy (2016) Trailer",
"webSearchUrl": "https://www.bing.com/videos/search?q=The%20Boy%20(2016)%20Trailer&FORM=VSTREQ",
"webSearchUrlPingSuffix": "DevEx,7602.1"
},
"image": {
"description": "Image from: traileraddict.com",
"thumbnailUrl": "https://tse3.mm.bing.net/th?id=OIP.M1d3053c1197438e029dfdfe0870aaef7o0&pid=Api",
"contentUrl": "http://cdn.traileraddict.com/content/stx-entertainment/the-boy-2016-2.jpg"
}
}
],
"title": "More movie trailers"
}
]
}
]
}
Code samples
@ECHO OFF
curl -v -X GET "https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending?" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.ajax({
url: "https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "GET",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending";
NSArray* array = @[
// Request parameters
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending');
$url = $request->getUrl();
$headers = array(
// Request headers
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('australiaeast.api.cognitive.microsoft.com')
conn.request("GET", "/bing/v7.0/videos/trending?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('australiaeast.api.cognitive.microsoft.com')
conn.request("GET", "/bing/v7.0/videos/trending?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://australiaeast.api.cognitive.microsoft.com/bing/v7.0/videos/trending')
uri.query = URI.encode_www_form({
})
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body