0
我正在嘗試通過發送用戶名和密碼使用post方法來發布到網址。但答案不明。無法從http服務器獲得響應
這是我如何做到這一點:
HttpClient httpclient =new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://test.res-novae.fr/xperia_orange/scripts/android_ckeck_user.php");
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
/*Checking response*/
if(response!=null)
{
InputStream in = response.getEntity().getContent();
System.out.println("Resultat de la server:"+in);
}
}
catch(ClientProtocolException e)
{
}
catch (IOException e) {
// TODO Auto-generated catch block
}
,這是從服務器的應答:
Resultat de la server:[email protected]
有誰知道我做錯了嗎?
我做到了:)...無論如何;) – adrian