【发布时间】:2011-11-12 19:11:41
【问题描述】:
我正在尝试通过 https 端点发出 GET 请求,我不确定是否需要任何特殊处理,但以下是我的代码:
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 并且说地址族不受协议支持
-
与 HTTPS 没有任何特定关系(因为服务器证书是 Android 的接受者,这是另一回事)。问题是 HTTPS 特有的吗?您是否尝试过在另一个 wibe 网站上使用和不使用 HTTPS 的另一个 URL?
-
hmmm...除了这个带有 https 的 URL 之外,我还没有真正尝试过其他人,我在 2.2.3
标签: java android httpclient