Android 发送http请求
(1)发送post请求
- Map<String,String> person = new HashMap<String,String>();
- person.put("os_version", SystemHWUtil.formatArr(version, ","));
- person.put("client_id", IMEI2);
- person.put("os_type", "android");
- // person.put("device_info", ShopUtil.get);
- ShopUtil.logger2("UIDRegisterTask url:" + url);
- // HttpSocketUtil2.setDetail(true);
- HttpSocketUtil2.httpRequest(url+"device/push_register", false/*ssl*/,
- person,
- SystemHWUtil.CONTENTTYPE_X_WWW_FORM_URLENCODED, null/*cookie*/,
- (Map) null, 5000, 5000);
后台以标准表单数据方式接收参数
(2)下载文件
- Map person = new HashMap();
- person.put("path", latestVersionUri);
- Object[] resultArr = HttpSocketUtil2
- .httpRequestDownload(
- url + "version/download",
- false,
- true,
- person,
- SystemHWUtil.CONTENTTYPE_JSON,
- ShopUtil.getSessionId(getApplicationContext())/* cookie */,
- TMP_UPDATE_FILE, SystemHWUtil.CHARSET_UTF,
- 15000, 15000);
后台接口接收到的请求体是json格式字符串
所以后台需要转换
时间: 2024-11-02 15:24:44