Nella mia app (la prima che realizzo) devo inviare una richiesta http ad uno script php che ho sul mio sito.
Assieme alla richiesta devo mandare dei parametri tramite post.
Lo sto facendo così
Mettendo dei messaggi ho visto che vado però sempre a finire nell'ultimo catch IOException.codice:public void postData(String from, String to, String date, String time, String searchby, String type, String orderby) { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://www.miosito.it/android/provahttp.php"); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("from", from)); /**** altri 6 parametri ****/ // Url Encoding the POST parameters try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException e) { // writing error to Log e.printStackTrace(); } // Making HTTP Request try { HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { // writing exception to log e.printStackTrace(); } catch (IOException e) { // writing exception to log e.printStackTrace(); } }
Lo script php funziona correttamente, mettendo il link su un browser lo script genera il file (vuoto se non passo parametri, ma lo crea).
Cosa sto sbagliando?

Rispondi quotando