[英]Google Map Api always return request_denied with HttpClient
String webURL = "https://maps.googleapis.com/maps/api/place/search/json";
Map<String,String> params = new HashMap<String,String>();
params.put("location", "24.8844879,67.175255");
params.put("radius", "500");
params.put("sensor", "true");
params.put("key", MY_KEY);
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(
webURL);
if(params!=null){
for(String param:params.keySet()){
client.getParams().setParameter(param, params.get(param).toString());
}
}
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
Why the above code always return me this error 为什么上面的代码总是返回我这个错误
"html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED"] “ html_attributions”:[],“结果”:[],“状态”:“ REQUEST_DENIED”]
I have also tried with this logic 我也尝试过这种逻辑
if(params!=null){
HttpParams httpParams = new BasicHttpParams();
for(String param:params.keySet()){
httpParams.setParameter(param, params.get(param).toString());
}
httpGet.setParams(httpParams);
}
Basically I am just trying to fetch some Results from GMapI. 基本上,我只是想从GMapI获取一些结果。 What seems to me that its not setting parameters with URL also give me an idea that how i can print the complete url which is executing at that time. 在我看来,它没有使用URL设置参数也使我有了一个想法,我可以如何打印当时正在执行的完整url。
我当时在想的只是在UTF-8中编码参数,此后我的问题就解决了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.