IP- IP2Coordinates Data Science Toolkit.
API-, , . , HTML5 Geolocation IP, Max Mind.
, . , API- Yahoo, WOEID ( API ).
. <?php . , , , print.
$user_ip = $_SERVER['REMOTE_ADDR'];
$url = 'http://www.datasciencetoolkit.org/ip2coordinates/';
$raw_geocode = json_decode( get_data( $url . $user_ip) );
if ('US' === $raw_geocode->$user_ip->country_code) {
$zip_code = $raw_geocode->$user_ip->postal_code;
printf('<p>Your zip code is: %s</p>', $raw_geocode->$user_ip->postal_code);
} else {
$zip_code = '97211';
printf('<p>Sorry, this app does not work in %s.</p>', $raw_geocode->$user_ip->country_name);
}
printf('<pre>%s</pre>', print_r($raw_geocode, true));
, $data =, :
$data = get_data("http://weather.yahooapis.com/forecastrss?p={$zip_code}&u=f");