dti70601 2013-06-23 13:42
浏览 219
已采纳

如何使用api获取城市名称

Below url is the api for getting the api for getting city and country name using the ip. But i have used the different parameters like json

$json = file_get_contents(" http://api.ipinfodb.com/v3/ip-city/?key=a2f2062d64fd705bbb32ce4c44e8ebb508d080990528d7cb4f1a0c5e7ddf5c1e&ip=".$ip."&format=json"); 
$json = json_decode($json,true); 
$city=$json['CityName'];

example url below for ip

 http://api.ipinfodb.com/v3/ip-city/?key=a2f2062d64fd705bbb32ce4c44e8ebb508d080990528d7cb4f1a0c5e7ddf5c1e&ip=74.125.45.100&format=json
  • 写回答

1条回答 默认 最新

  • doudun1029 2013-06-23 13:44
    关注

    The c in cityName is lowercase.

    $city = $json['cityName'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题