Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLinda de Haan
12,413 PointsThe NewsSearch class (JSON special paste result) and getting the API key
For those of you who can't get the JSON response and don't want to scour the internet to get one, here is the entire NewsSearch class from the project files so you don't have to get that from a JSON:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoccerStats
{
public class NewsSearch
{
public string _type { get; set; }
public Instrumentation instrumentation { get; set; }
public string readLink { get; set; }
public int totalEstimatedMatches { get; set; }
public Value[] value { get; set; }
}
public class Instrumentation
{
public string pingUrlBase { get; set; }
public string pageLoadPingUrl { get; set; }
}
public class Value
{
public string name { get; set; }
public string url { get; set; }
public string urlPingSuffix { get; set; }
public Image image { get; set; }
public string description { get; set; }
public Provider[] provider { get; set; }
public DateTime datePublished { get; set; }
public string category { get; set; }
public Clusteredarticle[] clusteredArticles { get; set; }
}
public class Image
{
public Thumbnail thumbnail { get; set; }
}
public class Thumbnail
{
public string contentUrl { get; set; }
public int width { get; set; }
public int height { get; set; }
}
public class Provider
{
public string _type { get; set; }
public string name { get; set; }
}
public class Clusteredarticle
{
public string name { get; set; }
public string url { get; set; }
public string urlPingSuffix { get; set; }
public string description { get; set; }
public Provider1[] provider { get; set; }
public object datePublished { get; set; }
public string category { get; set; }
}
public class Provider1
{
public string _type { get; set; }
public string name { get; set; }
}
}
1 Answer
Linda de Haan
12,413 PointsAlso to get the API key, go to the My APIs page: Go to your Azure account: https://azure.microsoft.com/en-us/try/cognitive-services/my-apis/ Click 'show all' Click 'Add' below the Bing Search APIs v7 Click the 'Search APIs' tab There you can get your API key for a 7 day free trial.
Chad Burns
2,759 PointsThis part no longer works as Microsoft seems to have moved its Bing Search API out of its cognitive services. I had to sign in to portal.azure.com, search for "Bing" and click on Bing Search APIs v7, create a resource, at which time it asked me to sign up, and since I had previous used up their trial, I had to choose a Pay-As-You-Go plan, then I was able to create it as a resource, and then find my API keys under the "Keys and Endpoint" section of the Bing Resource that I had created. Not simple :(
Chad Burns
2,759 PointsChad Burns
2,759 PointsThank you so much!