【发布时间】:2011-10-18 07:33:42
【问题描述】:
如何使用 HTTPS Post 请求将 JSON 格式的 Android 应用程序数据(mobileNumber 和消息)发送到服务器。请帮我。
【问题讨论】:
标签: android
如何使用 HTTPS Post 请求将 JSON 格式的 Android 应用程序数据(mobileNumber 和消息)发送到服务器。请帮我。
【问题讨论】:
标签: android
HttpClient httpclient =new DefaultHttpClient();
HttpPost httppost=new HttpPost(name of the website);
try{
JSONObject j = new JSONObject();
j.put("engineer", "me");
httppost.setEntity(new UrlEncodedFormEntity(j));
HttpResponse response = httpclient.execute(httppost);
/*Checking response*/
if(response!=null)
{
responseBody = EntityUtils.toString(response.getEntity());
}
if(responseBody.equals("ok"))
{
//...do something
}
} catch(ClientProtocolException e) {
} catch (IOException e) {
// TODO Auto-generated catch block
} catch(Exception e){
e.printStackTrace();
}
您也可以在这里查看:Android JSON HttpClient to send data to PHP server with HttpResponse
【讨论】: