Weather forecast from IP address

Recipe to get weather forecast from an IP address

Ingredients

Ruby

require 'net/http'
require 'json'
$ip = '208.67.222.222'
$latlong = Net::HTTP.get(URI('https://ipapi.co/' + $ip + '/latlong/')).split(",")
$weather = JSON.parse(Net::HTTP.get(URI('http://api.openweathermap.org/data/2.5/weather?lat='+$latlong[0]+'&lon='+$latlong[1]+'&appid='+$API_KEY)))

Python

from requests import get
ip = '208.67.222.222'
latlong = get('https://ipapi.co/{}/latlong/'.format(ip)).text.split(',')
weather = get('http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&appid=API_KEY'.format(latlong[0], latlong[1])).json()

PHP

$ip = '208.67.222.222';
$latlong = explode(",", file_get_contents('https://ipapi.co/' . $ip . '/latlong/'));
$weather = file_get_contents('http://api.openweathermap.org/data/2.5/weather?lat=' . $latlong[0] . '&lon=' . $latlong[1] . '&appid=API_KEY');
echo $weather;
$json = json_decode($weather);