private void OnCommandBing_AzureAPI(string Source, string Query)
{
try
{
Bing.BingSearchContainer SearchService = new Bing.BingSearchContainer(new Uri(BingAzureBaseURL));
SearchService.Credentials = new NetworkCredential(BingApplicationKey, BingApplicationKey);
DataServiceQuery<Bing.WebResult> ServiceQuery = SearchService.Web(Query, "en-US", "Moderate", null, null, null);
Bing.WebResult Result = ServiceQuery.Execute().FirstOrDefault();
if (Result == null)
SendMessage(SendType.Message, Source, "No results.");
else
SendMessage(SendType.Message, Source, String.Format("{0}: {1} - {2}", Result.Title, Result.Url, Result.Description));
}
catch (Exception)
{
SendMessage(SendType.Message, Source, String.Format("Unable to retrieve search results for {0}.", Query));
}
}