0
입니다. Google URL 단축 API를 사용하고 있습니다. 나는 "http://36.186.69.8:1339/는"이 오류를 반환 같은과이 URL "http://demos.companyname.com:1339/"를 교체 할 때 는 URL "http://demos.companyname.com:1339/"구글 URL URL에 대한 오류가 발생했습니다. IP 주소가
을 단축 만합니다.
이 문제를 해결하는 방법은 무엇입니까?
내 URL의 Lite 버전 코드
은 다음과 같습니다공개 된 JSONObject getJSONFromUrl (문자열 주소, 문자열 longUrl) {
// Making HTTP request
try {
// DefaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(address);
httpPost.setEntity(new StringEntity("{\"longUrl\":\""+ longUrl+"\"}"));
httpPost.setHeader("Content-Type", "application/json");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
is.close();
Log.e("getJSONFromUrl: ", sb.toString());
json = sb.toString();
Log.e("JSON", json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// Parse the String to a JSON Object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// Return JSON String
return jObj;
}
오류 응답 :
{"error":{"errors":
[{"domain":"global","reason":"invalid","message":"InvalidValue","locationType":"parameter","location":"resource.longUrl"}],"code":00,"message":"Invalid Value"}}