課程
/移動開發
/Android
/Android-Volley詳解
使用JsonObjectRequest POST請求為什么是錯誤的請求key,錯誤10001
2015-08-13
源自:Android-Volley詳解 2-2
正在回答
以JsonObject傳參數的時候,phone是int的,要求傳電話號碼的前7位 JsonObject jsonObject = new JsonObject(); ?jsonObject.put("phone",1354421); jsonObject.put("key","your key"); ?這樣是沒問題的,還有一點 ,從api中拿到的信息只是號碼一段的的位置信息即前7位 ?至于后面4位有還是沒有得到的信息都是一樣的。
Map<String,String>?map=new?HashMap<String,String>();
????????map.put("token",?"AbCdEfGh123456");
????????JSONObject?params=new?JSONObject(map);
?????????
????????RequestQueue?queue?=?Volley.newRequestQueue(this);
????????String?url?=?"http://m.weather.com.cn/data/101201401.html";
????????JsonObjectRequest?objRequest?=?new?JsonObjectRequest(url,?params,
????????????????new?Response.Listener<JSONObject>()?{
????????????????????@Override
????????????????????public?void?onResponse(JSONObject?obj)?{
????????????????????????System.out.println("----------:"?+?obj);
????????????????????}
????????????????},?new?Response.ErrorListener()?{
????????????????????public?void?onErrorResponse(VolleyError?error)?{
????????????????????????error.getMessage();
?
????????????????});
? ?
請使用StringRequest試一試,看問題出在哪里
舉報
最熱門網絡框架~快速入門大法,還等什么,快來學習吧
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-08-25
以JsonObject傳參數的時候,phone是int的,要求傳電話號碼的前7位 JsonObject jsonObject = new JsonObject(); ?jsonObject.put("phone",1354421); jsonObject.put("key","your key"); ?這樣是沒問題的,還有一點 ,從api中拿到的信息只是號碼一段的的位置信息即前7位 ?至于后面4位有還是沒有得到的信息都是一樣的。
2015-08-23
Map<String,String>?map=new?HashMap<String,String>();
????????map.put("token",?"AbCdEfGh123456");
????????JSONObject?params=new?JSONObject(map);
?????????
????????RequestQueue?queue?=?Volley.newRequestQueue(this);
????????String?url?=?"http://m.weather.com.cn/data/101201401.html";
????????JsonObjectRequest?objRequest?=?new?JsonObjectRequest(url,?params,
????????????????new?Response.Listener<JSONObject>()?{
????????????????????@Override
????????????????????public?void?onResponse(JSONObject?obj)?{
????????????????????????System.out.println("----------:"?+?obj);
????????????????????}
????????????????},?new?Response.ErrorListener()?{
????????????????????@Override
????????????????????public?void?onErrorResponse(VolleyError?error)?{
????????????????????????error.getMessage();
????????????????????}
?
????????????????});
? ?
2015-08-23
請使用StringRequest試一試,看問題出在哪里