在Android中发布基于webservice的请求
我开始使用Web服务在Android中发布基于webservice的请求,android,json,web-services,Android,Json,Web Services,我开始使用Web服务 Method Type: POST Request Parameters : {loginid:'xxxx@gmail.com', password:'yyyyy'} 我受到了如下的考验: JSONObject jObj = new JSONObject(); try { jObj.put("loginid", email.getText()); jObj.put("password", password.getText()); } 如何
Method Type: POST
Request Parameters : {loginid:'xxxx@gmail.com', password:'yyyyy'}
我受到了如下的考验:
JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}
如何为它编写JSON代码。这段代码有什么问题?
JSONObject jObj = new JSONObject();
try {
jObj.put("loginid", email.getText());
jObj.put("password", password.getText());
}
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("www.yoursite.com/page");
StringEntity se = new StringEntity(jObj.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
post.setEntity(se);
client.execute(post);