Android 如何使用Https Post请求将JsonObject发送到服务器

Android 如何使用Https Post请求将JsonObject发送到服务器,android,Android,如何使用HTTPS Post请求将JSON格式的android应用程序数据(mobileNumber和message)发送到服务器。请帮帮我 HttpClient httpclient =new DefaultHttpClient(); HttpPost httppost=new HttpPost(name of the website); try{ JSONObject j = new JSONObject(); j.put("engineer", "me");

如何使用HTTPS Post请求将JSON格式的android应用程序数据(mobileNumber和message)发送到服务器。请帮帮我

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();
}
您也可以在此处查看:


您也可以在这里查看:

谢谢。但是,它是基于HTTP工作的??还是HTTPS??你能告诉我吗。它对我来说是在Http上工作的,没有尝试过https。但是很简单:)。如果它有助于你不要忘记接受我的答案,请从左边检查它。谢谢:)我如何更改上面的代码以在https上工作??你能告诉我吗?很抱歉回复太晚了,但这似乎对http和https都有效!你试过了吗?它不起作用了?我没试过。但我想知道它是否也适用于“Https”?请你澄清一下,谢谢。但是,它是基于HTTP工作的??还是HTTPS??你能告诉我吗。它对我来说是在Http上工作的,没有尝试过https。但是很简单:)。如果它有助于你不要忘记接受我的答案,请从左边检查它。谢谢:)我如何更改上面的代码以在https上工作??你能告诉我吗?很抱歉回复太晚了,但这似乎对http和https都有效!你试过了吗?它不起作用了?我没试过。但我想知道它是否也适用于“Https”?你能给我澄清一下吗。