我使用發佈人來測試網址(後),它看起來不錯。 API:http://www.dmapp.com.tw/MobileApp/GetHealthData.php爲什麼我無法獲取json數據?
但是當我嘗試在我的機器人,我不能得到的消息,甚至我的響應代碼爲200
我logcat的顯示{"Msg":"Request method not accepted","JsonData":null,"ErrorCode":"0099"}
我不明白這一點,我用這個代碼很好地獲得了json數據。
有人可以教我什麼我想念它,這將不勝感激。
這裏是我的GET JSON數據功能:
private String getRoute(String url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
int responseCode = connection.getResponseCode();
StringBuilder jsonIn = new StringBuilder();
// responseCode show 200
Log.d("responseCode:",responseCode+"");
if (responseCode == 200) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
jsonIn.append(line);
}
} else {
Log.d(TAG, responseCode + "responseCode");
}
connection.disconnect();
// I can't get the json data it shows Request method not accepted
Log.d(TAG, jsonIn + "jsonIn");
return jsonIn.toString();
}
您鏈接的鏈接有這個呃ror消息。 – andras
謝謝我現在得到答案。 –