嘿,我正在为我在大学的最后一年项目开发一个应用程序,我正在努力使用默认的 http 客户端来模仿下面的帖子,因为它的格式似乎与我见过的其他人不同。我使用的代码与此类似,并且已成功登录该站点:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.myurl.com/app/page.php");
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("type", "20"));
nameValuePairs.add(new BasicNameValuePair("mob", "919895865899"));
nameValuePairs.add(new BasicNameValuePair("pack", "0"));
nameValuePairs.add(new BasicNameValuePair("exchk", "1"));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.d("myapp", "works till here. 2");
try {
HttpResponse response = httpclient.execute(httppost);
Log.d("myapp", "response " + response.getEntity());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
但是,我正在努力从下面的帖子中区分参数及其值,并且不确定数字 8743499427392 的用途。任何帮助将不胜感激:
(来自 Http Live Headers 的部分帖子)
http://messaging.o2online.ie/con_save.osp
POST /con_save.osp -----------------------------8743499427392
Content-Disposition: form-data; name="EContactID"
-1^
-----------------------------8743499427392
Content-Disposition: form-data; name="EContactIDList"
-----------------------------8743499427392
Content-Disposition: form-data; name="Categories"
Synch;
-----------------------------8743499427392
Content-Disposition: form-data; name="ENickName"
Test Colm Test Shannon
-----------------------------8743499427392
Content-Disposition: form-data; name="EAtt1"; filename=""
Content-Type: application/octet-stream
-----------------------------8743499427392
Content-Disposition: form-data; name="EPMobile"
0868617541
-----------------------------8743499427392
Content-Disposition: form-data; name="EMobile"
-----------------------------8743499427392--