私はAndroidアプリを書いています。次に、このメソッドを使用して URL から JSON を取得しようとします。
public String getInfo(String adress) throws Exception {
URL url = new URL(adress);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
int status = uc.getResponseCode();
InputStream in = uc.getInputStream();
InputStreamReader inRead = new InputStreamReader(in);
BufferedReader br = new BufferedReader(inRead);
String line;
String result = "";
while ((line = br.readLine()) != null) {
result += line;
}
return result;
}
この URL: http://www.rtvlansingerland.nl/tag/nieuws/?json=get_postsこのメソッドは、この URL で完全に機能しています: http://www.rtvlansingerland.nl/?json=get_post&id=24411ステータス変数が 400 になり、url not found 例外が発生しuc.getInputStream()
、filenotfound エラーが返されます。
ブラウザで URL を開くと、完全に有効な JSON が返されます (jsonlint で確認)。
何が間違っている可能性があるか、誰にも選択肢がありますか?
事前にthx。