{"id":1775,"date":"2024-11-10T14:00:06","date_gmt":"2024-11-10T06:00:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1775\/"},"modified":"2024-11-10T14:00:06","modified_gmt":"2024-11-10T06:00:06","slug":"%e4%ba%86%e8%a7%a3-http-%e6%96%b9%e6%b3%95%ef%bc%9aput-%e4%b8%8e-post-%e7%9a%84%e7%bb%bc%e5%90%88%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1775\/","title":{"rendered":"\u4e86\u89e3 HTTP \u65b9\u6cd5\uff1aPUT \u4e0e POST \u7684\u7efc\u5408\u6307\u5357"},"content":{"rendered":"<p>\u50cf put \u548c post \u8fd9\u6837\u7684 http \u65b9\u6cd5\u662f\u6211\u4eec\u5904\u7406 web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8d44\u6e90\u7684\u652f\u67f1\u3002\u5728\u8fd9\u672c\u4e00\u4f53\u5316\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u7814\u7a76\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5206\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\uff0c\u5e76\u786e\u5b9a\u4f55\u65f6\u5728 api \u8bbe\u7f6e\u4e2d\u4f7f\u7528\u6bcf\u79cd\u65b9\u6cd5\u3002<\/p>\n<h2> \u4ec0\u4e48\u662f put http \u65b9\u6cd5\uff1f <\/h2>\n<p>put \u662f\u5173\u4e8e\u5728\u7279\u5b9a url \u66f4\u65b0\u6216\u521b\u5efa\u8d44\u6e90\u3002\u4ee5\u4e0b\u662f put \u7684\u5185\u5e55\uff1a<\/p>\n<ul>\n<li> <strong>\u8d44\u6e90\u6807\u8bc6\uff1a<\/strong> url \u672c\u8eab\u5c31\u662f\u8d44\u6e90\u7684 id\u3002<\/li>\n<li> <strong>\u8bf7\u6c42\u6b63\u6587\uff1a<\/strong>\u5b83\u643a\u5e26\u5b8c\u6574\u7684\u3001\u66f4\u65b0\u7684\u8d44\u6e90\u3002<\/li>\n<li> <strong>\u5e42\u7b49\u6027\uff1a<\/strong> \u518d\u6b21\u53d1\u9001\u76f8\u540c\u7684 put \u8bf7\u6c42\uff1f\u4f60\u4f1a\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c\u3002<\/li>\n<li> <strong>\u8d44\u6e90\u5904\u7406\uff1a<\/strong>\u5982\u679c\u8d44\u6e90\u5b58\u5728\uff0c\u5b83\u5c06\u5b8c\u5168\u66ff\u6362\u4e3a\u8bf7\u6c42\u6b63\u6587\u4e2d\u7684\u5185\u5bb9\u3002\u5982\u679c\u4e0d\u662f\uff0c\u65b0\u8d44\u6e90\u5c31\u4f1a\u8bde\u751f\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u60f3\u7528\u65b0\u6570\u636e\u5b8c\u5168\u66ff\u6362\u73b0\u6709\u8d44\u6e90\uff0cput \u662f\u60a8\u4f7f\u7528 restful api \u7684\u9996\u9009\u3002<\/p>\n<h2> \u4ec0\u4e48\u662f post http \u65b9\u6cd5\uff1f <\/h2>\n<p>\u7136\u540e\u662fpost\uff0c\u5b83\u5c06\u6570\u636e\u63d0\u4ea4\u5230\u7279\u5b9a\u7684url\u4ee5\u521b\u5efa\u65b0\u8d44\u6e90\u3002\u4ee5\u4e0b\u662f\u60a8\u9700\u8981\u4e86\u89e3\u7684\u6709\u5173 post \u7684\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li> <strong>url \u5904\u7406\uff1a<\/strong> \u5b83\u544a\u8bc9\u8bf7\u6c42\u6570\u636e\u5c06\u5728\u54ea\u91cc\u5904\u7406\u3002<\/li>\n<li> <strong>\u8bf7\u6c42\u6b63\u6587\uff1a<\/strong> \u4fdd\u5b58\u7528\u4e8e\u5236\u4f5c\u65b0\u8d44\u6e90\u7684\u6570\u636e\u3002<\/li>\n<li> <strong>\u975e\u5e42\u7b49\uff1a<\/strong> \u4e24\u6b21\u6267\u884c\u76f8\u540c\u7684 post \u8bf7\u6c42\uff0c\u6bcf\u6b21\u53ef\u80fd\u4f1a\u5f97\u5230\u4e0d\u540c\u7684\u7ed3\u679c\u3002<\/li>\n<li> <strong>\u8d44\u6e90\u521b\u5efa\uff1a<\/strong>\u4e3b\u8981\u7528\u4e8e\u521b\u5efa\u65b0\u7684\u4e1c\u897f\uff0c\u6709\u65f6\u5b83\u53ef\u4ee5\u4e0e\u7a7a\u7684\u4e3b\u4f53\u4e00\u8d77\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>\u5f53\u60a8\u9700\u8981\u521b\u5efa\u65b0\u7684\u8d44\u6e90\u5b9e\u4f8b\uff08\u4f8b\u5982\u6dfb\u52a0\u65b0\u7528\u6237\u6216\u53d1\u5e03\u8bc4\u8bba\uff09\u65f6\uff0cpost \u975e\u5e38\u7075\u6d3b\u4e14\u65b9\u4fbf\u3002<\/p>\n<h2> put \u4e0e post \u7684\u5b9e\u9645\u5e94\u7528 <\/h2>\n<p>\u8ba9\u6211\u4eec\u901a\u8fc7\u4e00\u4e9b\u4f8b\u5b50\u6765\u770b\u770b\u8fd9\u4e24\u8005\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff1a<\/p>\n<pre>\/\/ put example\nput \/users\/1\n{\n  \"id\": 1,\n  \"name\": \"ichiro\",\n  \"age\": 22\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64 put \u8bf7\u6c42\u4f7f\u7528\u65b0\u4fe1\u606f\u66f4\u65b0 id \u4e3a 1 \u7684\u7528\u6237\u3002<\/p>\n<pre>\/\/ POST example\nPOST \/users\n{\n  \"name\": \"Saburo\",\n  \"age\": 18\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64 post \u8bf7\u6c42\u4f7f\u7528\u7ed9\u5b9a\u7684\u8be6\u7ec6\u4fe1\u606f\u521b\u5efa\u4e00\u4e2a\u5168\u65b0\u7684\u7528\u6237\u3002<\/p>\n<h2> put \u548c post \u4e4b\u95f4\u7684\u4e3b\u8981 <\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e3b\u8981\u533a\u522b\uff1a<\/p>\n<ul>\n<li> <strong>\u8bf7\u6c42\u6b63\u6587\uff1a<\/strong> put \u53d1\u9001\u5b8c\u6574\u66f4\u65b0\u7684\u8d44\u6e90\u3002 post \u53d1\u9001\u7528\u4e8e\u521b\u5efa\u65b0\u5185\u5bb9\u7684\u6570\u636e\u3002<\/li>\n<li> <strong>url \u7528\u6cd5\uff1a<\/strong> put \u76f4\u63a5\u6807\u8bc6\u8d44\u6e90\u3002 post \u6307\u5b9a\u8d44\u6e90\u5c06\u53bb\u5f80\u7684\u96c6\u5408\u3002<\/li>\n<li> <strong>\u5e42\u7b49\u6027\uff1a<\/strong> put \u8bf7\u6c42\u662f\u5e42\u7b49\u7684\uff08\u6bcf\u6b21\u7ed3\u679c\u76f8\u540c\uff09\u3002 post \u8bf7\u6c42\u4e0d\u662f\u3002<\/li>\n<li> <strong>\u8d44\u6e90\u5904\u7406\uff1a<\/strong> put \u66ff\u6362\u6574\u4e2a\u8d44\u6e90\u3002 post \u53ef\u4ee5\u90e8\u5206\u66f4\u65b0\u6216\u521b\u5efa\u65b0\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<h2> echoapi\uff1a\u652f\u6301\u6240\u6709http\u65b9\u6cd5 <\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173055712269484.jpg\" class=\"aligncenter\" title=\"\u4e86\u89e3 HTTP \u65b9\u6cd5\uff1aPUT \u4e0e POST \u7684\u7efc\u5408\u6307\u5357\u63d2\u56fe\" alt=\"\u4e86\u89e3 HTTP \u65b9\u6cd5\uff1aPUT \u4e0e POST \u7684\u7efc\u5408\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<p>echoapi \u662f\u7528\u4e8e api \u5f00\u53d1\u7684\u8d85\u8f7b\u91cf\u7ea7\u89e3\u51b3\u65b9\u6848\uff0c\u6beb\u4e0d\u8d39\u529b\u5730\u652f\u6301\u6240\u6709 http \u65b9\u6cd5\u3002\u65e0\u8bba\u60a8\u6b63\u5728\u5904\u7406 put\u3001post \u8fd8\u662f\u4efb\u4f55\u5176\u4ed6 http \u65b9\u6cd5\uff0cechoapi \u90fd\u53ef\u4ee5\u4e3a\u60a8\u63d0\u4f9b\u8bbe\u8ba1\u3001\u8c03\u8bd5\u3001\u81ea\u52a8\u5316\u6d4b\u8bd5\u548c\u8d1f\u8f7d\u6d4b\u8bd5\u5de5\u5177\u3002\u975e\u5e38\u9002\u5408\u66ff\u6362 postman\uff0c\u5177\u6709 \u3001vs code \u548c chrome \u8bf7\u6c42\u6355\u83b7\u6269\u5c55\u7684\u4fbf\u6377\u63d2\u4ef6\uff0c\u6240\u6709\u8fd9\u4e9b\u90fd\u65e0\u9700\u767b\u5f55\u3002<\/p>\n<ul>\n<li><strong>\u65e0\u9700\u767b\u5f55<\/strong><\/li>\n<li><strong>\u652f\u6301\u4fbf\u7b7e\u672c<\/strong><\/li>\n<li><strong>\u8d85\u8f7b<\/strong><\/li>\n<li><strong>100% \u517c\u5bb9 postman \u811a\u672c\u8bed\u6cd5<\/strong><\/li>\n<\/ul>\n<p>\u63a2\u7d22 echoapi \u5e76\u8ba9\u60a8\u7684 api \u5f00\u53d1\u8fc7\u7a0b\uff08\u4ece\u8bbe\u8ba1\u5230\u6d4b\u8bd5\u7b49\uff09\u66f4\u52a0\u987a\u7545\u3002\u4f7f\u7528 echoapi\uff0c\u7ba1\u7406 put \u548c post \u7b49 http \u65b9\u6cd5\u53d8\u5f97\u8f7b\u800c\u6613\u4e3e\u3002\u514d\u8d39\u5f00\u59cb\u4f7f\u7528 &#8211; \u7acb\u5373\u4f7f\u7528 echoapi \u5f00\u59cb\u60a8\u7684 api \u5f00\u53d1\u4e4b\u65c5\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4e86\u89e3 HTTP \u65b9\u6cd5\uff1aPUT \u4e0e POST \u7684\u7efc\u5408\u6307\u5357\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u50cf put \u548c post \u8fd9\u6837\u7684 http \u65b9\u6cd5\u662f\u6211\u4eec\u5904\u7406 web \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8d44\u6e90\u7684\u652f\u67f1\u3002\u5728\u8fd9\u672c\u4e00\u4f53\u5316\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u7814\u7a76\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5206\u89e3\u5b83\u4eec\u7684\u5dee\u5f02\uff0c\u5e76\u786e\u5b9a\u4f55\u65f6\u5728 api \u8bbe\u7f6e\u4e2d\u4f7f\u7528\u6bcf\u79cd\u65b9\u6cd5\u3002 \u4ec0\u4e48\u662f put http \u65b9\u6cd5\uff1f put \u662f\u5173\u4e8e\u5728\u7279\u5b9a url \u66f4\u65b0\u6216\u521b\u5efa\u8d44\u6e90\u3002\u4ee5\u4e0b\u662f put \u7684\u5185\u5e55\uff1a \u8d44\u6e90\u6807\u8bc6\uff1a url \u672c\u8eab\u5c31\u662f\u8d44\u6e90\u7684 id\u3002 \u8bf7\u6c42\u6b63\u6587\uff1a\u5b83\u643a\u5e26\u5b8c\u6574\u7684\u3001\u66f4\u65b0\u7684\u8d44\u6e90\u3002 \u5e42\u7b49\u6027\uff1a \u518d\u6b21\u53d1\u9001\u76f8\u540c\u7684 put \u8bf7\u6c42\uff1f\u4f60\u4f1a\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c\u3002 \u8d44\u6e90\u5904\u7406\uff1a\u5982\u679c\u8d44\u6e90\u5b58\u5728\uff0c\u5b83\u5c06\u5b8c\u5168\u66ff\u6362\u4e3a\u8bf7\u6c42\u6b63\u6587\u4e2d\u7684\u5185\u5bb9\u3002\u5982\u679c\u4e0d\u662f\uff0c\u65b0\u8d44\u6e90\u5c31\u4f1a\u8bde\u751f\u3002 \u56e0\u6b64\uff0c\u5982\u679c\u60a8\u60f3\u7528\u65b0\u6570\u636e\u5b8c\u5168\u66ff\u6362\u73b0\u6709\u8d44\u6e90\uff0cput \u662f\u60a8\u4f7f\u7528 restful api \u7684\u9996\u9009\u3002 \u4ec0\u4e48\u662f post http \u65b9\u6cd5\uff1f \u7136\u540e\u662fpost\uff0c\u5b83\u5c06\u6570\u636e\u63d0\u4ea4\u5230\u7279\u5b9a\u7684url\u4ee5\u521b\u5efa\u65b0\u8d44\u6e90\u3002\u4ee5\u4e0b\u662f\u60a8\u9700\u8981\u4e86\u89e3\u7684\u6709\u5173 post \u7684\u4fe1\u606f\uff1a url \u5904\u7406\uff1a \u5b83\u544a\u8bc9\u8bf7\u6c42\u6570\u636e\u5c06\u5728\u54ea\u91cc\u5904\u7406\u3002 \u8bf7\u6c42\u6b63\u6587\uff1a \u4fdd\u5b58\u7528\u4e8e\u5236\u4f5c\u65b0\u8d44\u6e90\u7684\u6570\u636e\u3002 \u975e\u5e42\u7b49\uff1a \u4e24\u6b21\u6267\u884c\u76f8\u540c\u7684 post \u8bf7\u6c42\uff0c\u6bcf\u6b21\u53ef\u80fd\u4f1a\u5f97\u5230\u4e0d\u540c\u7684\u7ed3\u679c\u3002 \u8d44\u6e90\u521b\u5efa\uff1a\u4e3b\u8981\u7528\u4e8e\u521b\u5efa\u65b0\u7684\u4e1c\u897f\uff0c\u6709\u65f6\u5b83\u53ef\u4ee5\u4e0e\u7a7a\u7684\u4e3b\u4f53\u4e00\u8d77\u4f7f\u7528\u3002 \u5f53\u60a8\u9700\u8981\u521b\u5efa\u65b0\u7684\u8d44\u6e90\u5b9e\u4f8b\uff08\u4f8b\u5982\u6dfb\u52a0\u65b0\u7528\u6237\u6216\u53d1\u5e03\u8bc4\u8bba\uff09\u65f6\uff0cpost \u975e\u5e38\u7075\u6d3b\u4e14\u65b9\u4fbf\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1775","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1775"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1775\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}