blahNow我在做一個ANdroid應用程序。在我的應用程序中,我必須使用url登錄。就像... www.blah.com/api/login/username/password。將數據從android傳遞到網站
private void sendAccelerationData()
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
nameValuePairs.add(new BasicNameValuePair("","test3"));
nameValuePairs.add(new BasicNameValuePair("","pass3"));
this.sendData(nameValuePairs);
}
private void sendData(ArrayList<NameValuePair> data)
{
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://blah.com/api/login/");
httppost.setEntity(new UrlEncodedFormEntity(data));
HttpResponse response = httpclient.execute(httppost);
}
}
,但我得到404 error.and如果我寫我的SendData()之類
HttpPost("http://eesnap.com");
和sendAccelerationData()之類
nameValuePairs.add(new BasicNameValuePair("","api"));
nameValuePairs.add(new BasicNameValuePair("","login"));
nameValuePairs.add(new BasicNameValuePair("","test3"));
nameValuePairs.add(new BasicNameValuePair("","pass3"));
我得到200次的成功。 如果布勞爾後www.blah.com/api/login/username/password然後我得到瀏覽器上的結果
http://eesnap.com/api/login/test3/pass3.Copy此網址的地址欄....你可以檢查 – sarath 2012-04-18 06:54:17