百度API獲取反編譯地理信息報240錯誤編碼APP 服務被禁用

status": 240,     "message": "APP 服務被禁用" 

先使用百度API獲取IP經緯度,再使用反編譯獲取經緯度的地理信息

經查看是百度更新了接口,老的接口

URL = "http://api.map.baidu.com/geocoder/v2/?callback=renderReverse&location=" + that.jingdu + "," + that.weidu + "&output=json&pois=1&latest_admin=1&ak=HmWt3r5SNn6bi6MBI4g5B03ad0pmRahX";

新的接口

'http://api.map.baidu.com/reverse_geocoding/v3/?ak=HmWt3r5SNn6bi6MBI4g5B03ad0pmRahX&output=json&coordtype=wgs84ll&location=' + latlon,

此處特別注意地理位置和參數有部分不同。

先貼正確代碼

 var latlon = null;
            //ajax獲取用戶所在經緯度
            $.ajax({
                url: "http://api.map.baidu.com/location/ip?ak=HmWt3r5SNn6bi6MBI4g5B03ad0pmRahX&coor=bd09ll",
                type: "POST",
                dataType: "jsonp",
                success: function(data) {
                    latlon = data.content.point.y + "," + data.content.point.x;
                    //ajax根據經緯度獲取省市區
                    $.ajax({
                        type: "POST",
                        dataType: "jsonp",
                        url: 'http://api.map.baidu.com/reverse_geocoding/v3/?ak=HmWt3r5SNn6bi6MBI4g5B03ad0pmRahX&output=json&coordtype=wgs84ll&location=' + latlon,
                        success: function(response) {
                            if (response.status == 0) {
                                console.log(response.result.addressComponent.province + "-" + response.result.addressComponent.city + "-" + response.result.addressComponent.district);
                                city = response.result.addressComponent.city;
                            }
                        }
                    });
                }
            });

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章