我试图让通过HTTPS端点的GET请求,我不知道是否有任何需要的特殊治疗,但下面是我的代码:如何通过http客户端执行https获取请求?
String foursquareURL = "https://api.foursquare.com/v2/venues/search?ll=" + latitude + "," + longitude + "&client_id="+CLIENT_ID+"&client_secret="+CLIENT_SECRET;
System.out.println("Foursquare URL is " + foursquareURL);
try {
Log.v("HttpClient", "Preparing to create a request " + foursquareURL);
URI foursquareURI = new URI(foursquareURL);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(foursquareURI));
content = response.getEntity().getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(content));
String strLine;
String result = "";
while ((strLine = br.readLine()) != null) {
result += strLine;
}
//editTextShowLocation.setText(result);
Log.v("result of the parser is", result);
} catch (Exception e) {
Log.v("Exception", e.getLocalizedMessage());
}
什么是错误? –
它总是遇到异常,说api.foursquare.com,它说地址家族不支持的协议 – adit
没有什么特别的与HTTPS(尽管服务器证书是由Android接受器,这是另一回事)。特定于HTTPS的问题?你有没有使用过HTTPS的另一个wibe网站上的另一个网址? – Thierry