Getting the news
Using the Bing News Search API, we can search for news in several ways. There are three endpoints we use for this API:
/news
: Get top news articles, based on category/news/search
: Get news articles based on a search query/news/trendingtopics
: Get top trending news topics
In our smart-house application, we will add the first two, while we will only cover the last one theoretically.
Note
If you have not already done so, sign up for the Bing News Search API at https://portal.azure.com.
News from queries
A lot of the groundwork for query-based news searches have already been done in the web search sample. To search for news based on given queries, we need to add a new function in the BingSearch
class.
Open the BingSearch.cs
file and add a new function called SearchNews
. This should accept a string
and a SafeSearch
parameter. The function should be marked as async
, and return a Task<BingNewsResponse>
object:
public async Task<BingNewsResponse> SearchNews(string query, SafeSearch...