I was trying to use the HttpRequest methods on java but it doesn't work, this is my code
package com.example.phpconnect;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import android.util.Log;
public class httpHandler {
public String post(String posturl){
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(posturl);
Log.w("Se envio","Fase 1");
HttpResponse resp = httpclient.execute(httppost);
HttpEntity ent = resp.getEntity();
Log.w("Se envio","Fase 2");
String text = EntityUtils.toString(ent);
Log.w("Se envio","Fase 3");
return text;
}
catch(Exception e){
Log.w("Se envio","Error");
return "Error";
}
}
}
It works fine up to the first log, then it throws the error, please some one know where the problem is? thanks!