2011-08-02 30 views

答えて

1
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

+0

ありがとうございました。しかし、それはHTTPに基づいて動作しますか?またはHTTPS ??私に教えてください。 – Santhosh

+0

それは私のためにHttpで動作し、https.Butで試していない何か非常に簡単です:)それはあなたが私の答えを受け入れることを忘れないように役立つ場合は、左側からチェックしてください。おかず:) – adrian

+0

どうすればよいですか? HTTPS上で動作するように上記のコードを変更しますか?私に教えてください。 – Santhosh

関連する問題