blahNow 我正在做一个安卓应用程序。在我的应用程序中,我必须使用 url 登录。就像...www.blah.com/api/login/username/password。
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 错误。如果我像这样写我的 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 那么我会在浏览器上得到结果