Skip to content

This repository is to get weather data using city name or country name.

Notifications You must be signed in to change notification settings

sathir/openweather_api_php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openweather_api_php

This repository is to get weather data using city name or country name.

Initial Setup

#HTML Code to Show Weather Forecasts

HTML code is used to display the weather forecast by decoding the JSON object response. In this section, we access the location, weather description, icon, min-max ranges of the temperature, humidity and wind speed.

#POSTMAN Setup postman_collection file is included for import

postman_collection.json

Development environment set up

###Build from root

docker-compose -f docker-compose.yml build

###Run the container

docker-compose -f docker-compose.yml up -d

Weather API will be available at http://localhost:8800/

Execution

###SET YOUR API KEY HERE

function getWeatherReport($city){
    $api_key = "SET YOUR API KEY HERE";
}

Goals

What?

  • PHP application to display weather forecast information using an API. I have used OpenWeatherMap service to implement this with PHP. We will just grab the weather information provided by the API and display it in the application.

Why?

  • This is one of the best API service that provides weather forecast. It provides tremendous volume of weather data regularly. It is a free service with limited access. For basic usage, it should be sufficient.

How?

  • The following three steps are used for the integration.
    • Get API key
    • Locate city id
    • Request weather forecast by sending API key and city id

Get OpenWeatherMap API key

  • To get the API key, we need to register with OpenWeatherMap. After signing up, it will redirect us to the profile settings.
  • Above the profile settings form, there is a top menu containing several tabs. Click the API keys tab and copy the API key. This will be later used to request API for the weather forecasts.

About

This repository is to get weather data using city name or country name.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published