public void GetWeather(string city) { WeatherConditions weatherConditions = new WeatherConditions(); var client = new OpenWeatherAPI.OpenWeatherAPI("d9a69d574ef7c5bdccdc52b2b0b13458"); var results = client.Query(city); if (client != null) { weatherConditions.CurentTemperature = results.Main.Temperature.CelsiusCurrent; weatherConditions.Direction = results.Wind.Direction; weatherConditions.MaxTemperature = results.Main.Temperature.CelsiusMaximum; weatherConditions.MinTemperature = results.Main.Temperature.CelsiusMaximum; weatherConditions.SeaLevel = results.Main.SeaLevelAtm; weatherConditions.WindSpeedMetersPerSecond = results.Wind.SpeedMetersPerSecond; //weatherConditions.RainLevel = results.Rain.H3; weatherConditions.Degri = results.Wind.Degree; weatherConditionsOld = weatherConditions; weatherConditions.Cyti = city; countGet += 1; weatherConditions.CountCondition = countGet; EventNewWeatherConditions(weatherConditions); } }
static void Main(string[] args) { var client = new OpenWeatherAPI.OpenWeatherAPI("6ac232d2dac00bdaa191f6d3db9cbeec"); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); synthesizer.SelectVoiceByHints(VoiceGender.Female); Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\Users\\Mi'Angel\\Downloads\\Genesis-1ac8c357b5fb.json"); synthesizer.Speak("Hello. I'm Genesis."); StreamingMicRecognizeAsync(2).Wait(); Console.WriteLine(speechResult); if (speechResult.Contains("weather")) { // Get location var city = "Phoenix, Arizona"; //Get API result //To get tomorrow or yesterdays weather or a forecast, we can use a switch statement to return a result //as a subContains if speech aslo contains today, tomorrow synthesizer.Speak($"Fetching weather data for '{city}'"); var results = client.Query(city); synthesizer.Speak($"The temperature in {city} is {results.Main.Temperature.FahrenheitCurrent} degrees. There is {results.Wind.SpeedFeetPerSecond.ToString("0")} feet per second wind in the {results.Wind.Direction} direction."); } }
public IActionResult Index() { var client = new OpenWeatherAPI.OpenWeatherAPI("7b678f7b3998ff5249745148d5c8a38a"); var results = client.Query("London"); return(View(results)); }
public IActionResult Index(string city) { var client = new OpenWeatherAPI.OpenWeatherAPI("7b678f7b3998ff5249745148d5c8a38a"); try { if (city == null) { city = "London"; } var results = client.Query(city); return(View(results)); } catch (Exception ex) { return(View(ex.Message)); } }
static void Main(string[] args) { var client = new OpenWeatherAPI.OpenWeatherAPI("YOUR-API-KEY"); Console.WriteLine("OpenWeatherAPI Example Application"); Console.WriteLine(); Console.WriteLine("Enter city to get weather data for:"); var city = Console.ReadLine(); Console.WriteLine(); Console.WriteLine($"Fetching weather data for '{city}'"); var results = client.Query(city); Console.WriteLine($"The temperature in {city} is {results.Main.Temperature.FahrenheitCurrent}F. There is {results.Wind.SpeedFeetPerSecond} f/s wind in the {results.Wind.Direction} direction."); Console.ReadLine(); }
private static void ClientInitialization() { string APIkey = ConfigurationManager.AppSettings["openWeatherAPIKey"].ToString(); client = new OpenWeatherAPI.OpenWeatherAPI(APIkey); }
public WeatherForm() { InitializeComponent(); client = new OpenWeatherAPI.OpenWeatherAPI("ce531910882f15ceff62669249965998"); pubIp = new WebClient().DownloadString("https://api.ipify.org"); }