How to use openweathermap api key?

I have an openweathermap api key, but how can I use it in PHP? and the weather report should be a report on behalf of the city, not the location of the weather ID

+5
source share
1 answer

How to use the API key

Add the following parameter to the GET request: APPID = APIKEY Example: api.openweathermap.org/data/2.5/forecast/city?APPID= YOURAPIKEY and what you want to request.

<?php $request = 'http://api.openweathermap.org/data/2.5/forecast/city?APPID=***YOURAPIKEY***'; $response = file_get_contents($request); $jsonobj = json_decode($response); print_r($jsonobj); ?> 

To request specific information, just look at the keys that the API accepts and adds to the end of the KEY = VAL URL.

An example would be

http://api.openweathermap.org/data/2.5/weather?APPID=YourAPIKey&q=London

I would also like to add when working with the API, I recommend installing a plugin to view JSON. I got JSONView installed as Google Chrome extension which is great for json view.

https://chrome.google.com/webstore/search/jsonview?hl=en

+13
source

Source: https://habr.com/ru/post/1201444/


All Articles