SK: YjrTc4pSX7HC90WwOJ3yaJZXAUaR9k
腾讯固定的获取IP位置的请求地址如下:
https://apis.map.qq.com/ws/location/v1/ip?ip=0.0.0.0&key=xxxxxxx
KEY的签名校验
腾讯API是这样介绍签名校验这个验证方法的

简单来说它的意思是这样的:
假如你没有用签名校验前的请求是这样写的:
https://apis.map.qq.com/ws/location/v1/ip?ip=0.0.0.0&key=xxxxxxx
那么用了签名校验就要换成如下:
https://apis.map.qq.com/ws/location/v1/ip?ip=0.0.0.0&key=xxxxxxx&sig=yyyyyy
那么,我们有key与sk,但是没有sig, sig是这样生成的,需要我们进行一次MD5计算
String kk = key + sk;String input_api = "/ws/location/v1/ip?ip="+ip+"&key="+kk;String sig = MD5.encrypt(input_api);
拿到sig之后,得到最终的请求url:
String url = "https://apis.map.qq.com/ws/location/v1/ip?ip="+ip +"&key="+key+"&sig="+sig;
只要i请求这个地址,把你要定位的ip传进去,腾讯就能将该IP所在的城市,经纬度等等返回给你。
Java代码String url = "https://apis.map.qq.com/ws/location/v1/ip?ip="+ip +"&key="+key+"&sig="+pwd;HttpClient client = new DefaultHttpClient();//发送get请求HttpGet request = new HttpGet(url);HttpResponse response = client.execute(request);/请求发送成功,并得到响应/if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { /读取服务器返回过来的json字符串数据/ String strResult = EntityUtils.toString(response.getEntity()); Map map = JSONObject.parseObject(strResult,Map.class); return map;}return null;
传入一个上海的IP:222.73.145.207
结果:
地图webServiceAPI:https://lbs.qq.com/service/webService/webServiceGuide/webServiceOverview
地图JavaScriptAPI:https://lbs.qq.com/webApi/javascriptGL/glGuide/glOverview