GET和POST方式請求API介面資料返回
GET在瀏覽器回退時是無害的,而POST會再次提交請求。
GET產生的URL地址可以被Bookmark,而POST不可以。
GET請求會被瀏覽器主動cache,而POST不會,除非手動設定。
GET請求只能進行url編碼,而POST支援多種編碼方式。
GET請求引數會被完整保留在瀏覽器歷史記錄裡,而POST中的引數不會被保留。
GET請求在URL中傳送的引數是有長度限制的,而POST麼有。
對引數的資料型別,GET只接受ASCII字元,而POST沒有限制。
GET比POST更不安全,因為引數直接暴露在URL上,所以不能用來傳遞敏感資訊。
GET引數透過URL傳遞,POST放在Request body中。
特別:
GET和POST還有一個重大區別,簡單的說:
GET產生一個TCP資料包;POST產生兩個TCP資料包。
長的說:
對於GET方式的請求,瀏覽器會把http header和data一併傳送出去,伺服器響應200(返回資料);
而對於POST,瀏覽器先傳送header,伺服器響應100 continue,瀏覽器再傳送data,伺服器響應200 ok(返回資料)。
但是:
1. GET與POST都有自己的語義,不能隨便混用。
2. 據研究,在網路環境好的情況下,發一次包的時間和發兩次包的時間差別基本可以無視。而在網路環境差的情況下,兩次包的TCP在驗證資料包完整性上,有非常大的優點。
3. 並不是所有瀏覽器都會在POST中傳送兩次包,Firefox就只傳送一次。
返回的資料是一樣的,如下所示
{ "item": { "num_iid": "652874751412", "title": "北歐輕奢布藝沙發 小戶型簡約現代客廳ins風網紅款三雙人訂製沙發", "desc_short": "", "price": "480.00", "total_price": 0, "suggestive_price": 0, "orginal_price": "3400.00", "nick": "惜情yqq1127", "num": 1550, "min_num": 0, "detail_url": " "pic_url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg", "brand": "#0 工廠", "brandId": null, "rootCatId": "50008164", "cid": "50020632", "crumbs": [], "created_time": "", "modified_time": "", "delist_time": "", "desc": "<div > \n <div >\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n <img src=\"!!2568161054.jpg\" />\n </div> \n </div><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-4.6438c7992c849&p=1778786741&k=i_key&t=1681442715\" style=\"display:none\" />", "desc_img": [ "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg", "!!2568161054.jpg" ], "item_imgs": [ { "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN01aYBriY1Jem9UDtt9e_!!2568161054.jpg" }, { "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01kjOfNb1Jem9DmWn8Y_!!2568161054.jpg" }, { "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN01HoB9ha1Jem9DmWn8r_!!2568161054.jpg" }, { "url": "//img.alicdn.com/imgextra/i4/2568161054/O1CN011PjP2P1Jem9MXEUFT_!!2568161054.jpg" }, { "url": "//img.alicdn.com/imgextra/i3/2568161054/O1CN01KUfBFL1Jem9KTTMn1_!!2568161054.jpg" } ], "item_weight": "", "item_size": "", "location": "江蘇南通", "post_fee": "", "express_fee": null, "ems_fee": "", "shipping_to": "", "has_discount": "true", "video": { "url": null }, "is_virtual": "", "sample_id": "", "is_promotion": "true", "props_name": "31480:14306495906:幾人坐:腳踏90*60*48cm;31480:14306495907:幾人坐:雙人165*95*67cm;31480:14306495908:幾人坐:三人210*95*67cm;31480:14306495909:幾人坐:單人100*95*67cm;31480:21480914361:幾人坐:四人位240*95*67cm;31480:21480914362:幾人坐:大四人320*95*76cm;31480:1387571900:幾人坐:3米貴妃沙發;31480:32527954:幾人坐:定製尺寸;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "prop_imgs": { "prop_img": [ { "properties": "1627207:28321", "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg" } ] }, "property_alias": "", "props": [ { "name": "品牌", "value": "#0 工廠" }, { "name": "型號", "value": "520" }, { "name": "材質", "value": "木" }, { "name": "木質材質", "value": "松木" }, { "name": "面料", "value": "絨布" }, { "name": "風格", "value": "北歐" }, { "name": "幾人坐", "value": "腳踏90*60*48cm,雙人165*95*67cm,三人210*95*67cm,單人100*95*67cm,四人位240*95*67cm,大四人320*95*76cm,3米貴妃沙發,定製尺寸" }, { "name": "顏色分類", "value": "乳白色" }, { "name": "填充物", "value": "海綿" }, { "name": "結構工藝", "value": "木質工藝" }, { "name": "是否可定製", "value": "是" }, { "name": "沙發組合形式", "value": "U形" }, { "name": "是否可拆洗", "value": "是" }, { "name": "適用物件", "value": "成年人" }, { "name": "是否帶儲物空間", "value": "否" }, { "name": "產地", "value": "上海" }, { "name": "地市", "value": "上海市" }, { "name": "區縣", "value": "奉賢區" }, { "name": "是否組裝", "value": "否" }, { "name": "計程車是否可運輸", "value": "否" }, { "name": "填充物硬度", "value": "軟" }, { "name": "款式定位", "value": "經濟型" } ], "total_sold": null, "skus": { "sku": [ { "price": "480", "total_price": 0, "orginal_price": "480", "properties": "31480:14306495906;1627207:28321", "properties_name": "31480:14306495906:幾人坐:腳踏90*60*48cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "4881047531343" }, { "price": "1688", "total_price": 0, "orginal_price": "1688", "properties": "31480:14306495907;1627207:28321", "properties_name": "31480:14306495907:幾人坐:雙人165*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "150", "sku_id": "4881047531344" }, { "price": "2088", "total_price": 0, "orginal_price": "2088", "properties": "31480:14306495908;1627207:28321", "properties_name": "31480:14306495908:幾人坐:三人210*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "4881047531345" }, { "price": "968", "total_price": 0, "orginal_price": "968", "properties": "31480:14306495909;1627207:28321", "properties_name": "31480:14306495909:幾人坐:單人100*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "4881047531346" }, { "price": "2388", "total_price": 0, "orginal_price": "2388", "properties": "31480:21480914361;1627207:28321", "properties_name": "31480:21480914361:幾人坐:四人位240*95*67cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "5039985183001" }, { "price": "3188", "total_price": 0, "orginal_price": "3188", "properties": "31480:21480914362;1627207:28321", "properties_name": "31480:21480914362:幾人坐:大四人320*95*76cm;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "5039985183002" }, { "price": "3400", "total_price": 0, "orginal_price": "3400", "properties": "31480:1387571900;1627207:28321", "properties_name": "31480:1387571900:幾人坐:3米貴妃沙發;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "5039984824000" }, { "price": "3000", "total_price": 0, "orginal_price": "3000", "properties": "31480:32527954;1627207:28321", "properties_name": "31480:32527954:幾人坐:定製尺寸;1627207:28321:顏色分類:乳白色 尺寸顏色可定製", "quantity": "200", "sku_id": "5039985183003" } ] }, "seller_id": "2568161054", "sales": 35, "shop_id": "567158267", "props_list": { "31480:14306495906": "幾人坐:腳踏90*60*48cm", "31480:14306495907": "幾人坐:雙人165*95*67cm", "31480:14306495908": "幾人坐:三人210*95*67cm", "31480:14306495909": "幾人坐:單人100*95*67cm", "31480:21480914361": "幾人坐:四人位240*95*67cm", "31480:21480914362": "幾人坐:大四人320*95*76cm", "31480:1387571900": "幾人坐:3米貴妃沙發", "31480:32527954": "幾人坐:定製尺寸", "1627207:28321": "顏色分類:乳白色 尺寸顏色可定製" }, "seller_info": { "nick": "惜情yqq1127", "item_score": "4.9 ", "score_p": "4.9 ", "delivery_score": "4.9 ", "shop_type": "C", "user_num_id": "2568161054", "sid": "567158267", "title": "現代布藝沙發", "zhuy": " "shop_name": "現代布藝沙發" }, "tmall": false, "error": "", "warning": "", "url_log": [], "fav_count": "7436", "fans_count": "644", "freight": "平郵: 快遞包郵", "props_imgs": { "prop_img": [ { "properties": "1627207:28321", "url": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg" } ] }, "_ddf": "fu", "promo_type": null, "props_img": { "1627207:28321": "//img.alicdn.com/imgextra/i1/2568161054/O1CN017GTZ4h1Jem9Qra1ap_!!2568161054.jpg" }, "format_check": "ok", "shop_item": [], "relate_items": [] }, "error": "", "secache": "4ad7ad2480af253fec9c2fd4daa266bb", "secache_time": 1681442715, "secache_date": "2023-04-14 11:25:15", "translate_status": "", "translate_time": 0, "language": { "default_lang": "cn", "current_lang": "cn" }, "reason": "", "error_code": "0000", "cache": 0, "api_info": "today:30 max:10100 all[69=30+21+18];expires:2030-12-31", "execution_time": "1.872", "server_time": "Beijing/2023-04-14 11:25:15", "client_ip": "106.6.33.181", "call_args": { "num_iid": "652874751412", "is_promotion": "1" }, "api_type": "taobao", "translate_language": "zh-CN", "translate_engine": "baidu", "server_memory": "0.94MB", "request_id": "gw-4.6438c7992c849", "last_id": "1677743647" }
展示效果
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70026630/viewspace-2945747/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PHP與Curl採用的GET,POST,JSON方式請求APIPHPJSONAPI
- 介面請求 (get、post、head 等) 詳解
- 介面請求(get、post、head等)詳解
- java傳送GET和post請求Java
- 淺談HTTP中GET和POST請求方式的區別HTTP
- ajax 請求的時候 get 和 post 方式的區別?
- vue axios資料請求get、post方法的使用VueiOS
- 前端常見的請求資料彙總(GET POST)前端
- GoWeb開發_Iris框架講解(二):Get、Post、Put等請求及資料返回格式GoWeb框架
- 優雅地使用GET和POST請求方法
- http請求之get和post的區別HTTP
- python3 實現 get 和 post 請求Python
- get和post請求的區別(面試)面試
- POST與GET請求區別
- 前後端資料互動(八)——請求方法 GET 和 POST 區別後端
- vue 發起get請求和post請求Vue
- get請求和post請求的區別
- Http請求get與post請求方式的各種相關面試總結HTTP面試
- cURL實現傳送Get和Post請求(PHP)PHP
- http請求中get和post方法的區別HTTP
- 原生js實現Ajax請求,包含get和postJS
- SpringMVC中如何傳送GET請求、POST請求、PUT請求、DELETE請求。SpringMVCdelete
- axios 發get,post 請求小結iOS
- get與post的請求區別
- Java Http Get Post 請求工具類JavaHTTP
- go對get、post請求封裝Go封裝
- get,post URL加字尾請求
- uni-app的POST請求和GET請求APP
- GET和POST兩種基本請求方法的區別
- Linux curl 命令模擬 POST/GET 請求Linux
- httprequest- post- get -傳送請求HTTP
- file_get_contents傳送post請求
- Post請求域名Nginx返回405報錯Nginx
- ajax的post或者get伺服器請求伺服器
- postman(二):使用postman傳送get or post請求Postman
- RestTemplate exchange GET POST請求傳引數DEMOREST
- Python中get、post請求詳解(HTTP請求頭、狀態碼)PythonHTTP
- ajax請求servlet返回資料Servlet