Code
$json = file_get_contents('http://freegeoip.appspot.com/json/66.102.13.106');
$expression = json_decode($json);
print_r($expression);
Result
stdClass Object
(
[status] => 1
[ip] => 66.102.13.106
[countrycode] => US
[countryname] => United States
[regioncode] => CA
[regionname] => California
[city] => Mountain View
[zipcode] => 94043
[latitude] => 37.4192
[longitude] => -122.057
)
To get countryname
echo $expression->countryname;
Result
United States
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…