0
一个JSON web服务和处理数据
我试图消耗低于消耗的Android
http://62.253.195.179/disaster/webservices/login.php?message=[{"email":"[email protected]","password":"welcome"}]
一个web服务这会返回一个JSON阵列
[{"companyuserId":"2","name":"ben stein","superiorname":"Leon","departmentId":"26","departmentname":"Development","companyId":"23","UDID":"12345","isActive":"1","devicetoken":"12345","email":"[email protected]","phone":"5456465465654","userrole":"1","chngpwdStatus":"1"}]
我的代码如下
try{
String weblink = URLEncoder.encode("http://62.253.195.179/disaster/webservices/login.php?message=[{\"email\":\"[email protected]\",\"password\":\"welcome\"}]");
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 7500;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
int timeoutSocket = 7500;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet request = new HttpGet();
URI link = new URI(weblink);
request.setURI(link);
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
result = rd.readLine();
JSONObject myData = new JSONObject(result);
JSONArray jArray = myData.getJSONArray("");
JSONObject steps = jArray.getJSONObject(0);
String name = steps.getString("name");
} catch (JSONException e) {
e.printStackTrace();
}
但它不工作,我不是100%确定这是做到这一点的最好方法。
11-10 10:49:55.489: E/AndroidRuntime(392): java.lang.IllegalStateException: Target host must not be null, or set in parameters.