我已输入信用卡信息并购买了“Google Maps API v2”,“Google Maps API v3”和“Google Maps Geolocation API”。我确信我的API_key是正确的。但是当我的android应用程序查询地理定位服务器时,服务器每次都返回403(Access Not Configured)。
我的项目编号是663182082293,项目编号是trustgo.com:trustgo。任何帮助深表感谢。提前谢谢!
电子邮件:shien01@baidu.com
Follwing是我的请求代码:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyChtmYL9zXe0XNhZQeThF8A9t_YpQ-E1p8");
try {
JSONObject holder = new JSONObject();
holder.put("homeMobileCountryCode", cell.MCC);
holder.put("homeMobileNetworkCode", cell.MNC);
holder.put("radioType", "gsm");
holder.put("carrier", "samsung");
JSONObject cellTower = new JSONObject();
cellTower.put("cellId", cell.CID);
cellTower.put("locationAreaCode", cell.LAC);
cellTower.put("mobileCountryCode", cell.MCC);
cellTower.put("mobileNetworkCode", cell.MNC);
cellTower.put("age", 0);
cellTower.put("signalStrength", -60);
cellTower.put("timingAdvance", 15);
JSONArray cellTowerarray = new JSONArray();
cellTowerarray.put(cellTower);
holder.put("cellTowers", cellTowerarray);
JSONObject wifiTower = new JSONObject();
WifiManager wm = (WifiManager) MainActivity.this
.getApplicationContext().getSystemService(
Context.WIFI_SERVICE);
wm.getDhcpInfo();
List<WifiConfiguration> list = wm.getConfiguredNetworks();
WifiConfiguration wif;
WifiInfo wifiInfo = wm.getConnectionInfo();
List<ScanResult> results = wm.getScanResults();
if (results != null && results.size() > 0) {
JSONArray wifiTowerarray = new JSONArray();
String wifimac = wifiInfo.getMacAddress();
int strength = wifiInfo.getRssi();
wifiTower.put("macAddress", wifimac);
wifiTower.put("signalStrength", strength);
wifiTower.put("age", 0);
wifiTower.put("channel", 2417);
wifiTower.put("signalToNoiseRatio", -85);
wifiTowerarray.put(wifiTower);
holder.put("wifiAccessPoints", wifiTowerarray);
}
StringEntity query = new StringEntity(holder.toString());
query.setContentType("application/json");
post.setEntity(query);
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
BufferedReader buffReader = new BufferedReader(
new InputStreamReader(entity.getContent()));
StringBuffer strBuff = new StringBuffer();
String result = null;
while ((result = buffReader.readLine()) != null) {
strBuff.append(result);
}
JSONObject json = new JSONObject(strBuff.toString());
String str1 = json.getString("location");
JSONObject subjosn = new JSONObject(str1);
itude.latitude = subjosn.getString("latitude");
itude.longitude = subjosn.getString("longitude");
} catch (Exception e) {
Log.e(e.getMessage(), e.toString());
} finally {
post.abort();
client = null;
}
答案 0 :(得分:0)
您是否已通过Google Play API COnsole激活Google Play服务?如果没有,请检查一次,转到Google API控制台 - &gt;使用您的Gmail登录&gt;在Console的左上角,单击Services-&gt;你会在那里看到很多Google服务 - &gt;如果需要,请选择Google Maps Android API v2和Google Maps API v2以及Google Maps API v3和其他任何内容。