{"id":16408,"date":"2023-11-18T04:05:27","date_gmt":"2023-11-17T20:05:27","guid":{"rendered":"https:\/\/www.linuxcool.com\/lmlkssxpqqqs"},"modified":"2023-11-18T04:05:27","modified_gmt":"2023-11-17T20:05:27","slug":"lmlkssxpqqqs","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/lmlkssxpqqqs","title":{"rendered":"Linux Curl\u547d\u4ee4\u5feb\u901f\u5b9e\u73b0POST\u8bf7\u6c42\uff0c\u8f7b\u677e\u53d1\u9001\u6570\u636e"},"content":{"rendered":"<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>1.\u4ec0\u4e48\u662fCurl<a style='color:#0000CC' href='https:\/\/www.linuxcool.com\/' target='_blank' rel=\"noopener\">\u547d\u4ee4<\/a>\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>Curl\u547d\u4ee4\u662f\u4e00\u79cd\u7528\u4e8e\u53d1\u9001\u548c\u63a5\u6536HTTP\u8bf7\u6c42\u7684\u5de5\u5177linux\u4e0b\u8f7d\uff0c\u5b83\u652f\u6301\u5404\u79cd\u534f\u8bae\uff0c\u5305\u62ecHTTP\u3001HTTPS\u3001FTP\u7b49\u3002\u5b83\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8fdb\u884c\u64cd\u4f5c\uff0c\u975e\u5e38\u65b9\u4fbf\u5feb\u6377\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>2. Curl\u547d\u4ee4\u5982\u4f55\u53d1\u9001POST\u8bf7\u6c42\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><img style='max-height:350px;max-width:80%;margin: 10px auto' src='https:\/\/www.linuxcool.com\/wp-content\/uploads\/2023\/11\/1700251526309_0.jpg' alt='linux curl \u547d\u4ee4 post_\u547d\u4ee4\u65b9\u5757\u6307\u4ee4_\u547d\u4ee4\u82f1\u6587' \/><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8981\u53d1\u9001POST\u8bf7\u6c42\uff0c\u53ef\u4ee5\u4f7f\u7528Curl\u547d\u4ee4\u7684-d\u6216--data\u9009\u9879\uff0c\u540e\u8ddf\u8981\u53d1\u9001\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0ccurl -d&#8221;username=admin&amp;password=123456&#8243;  \u53ef\u4ee5\u5411\u53d1\u9001\u4e00\u4e2aPOST\u8bf7\u6c42\uff0c\u5e76\u5e26\u4e0a\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>3.\u5982\u4f55\u5728Curl\u547d\u4ee4\u4e2d\u8bbe\u7f6e\u8bf7\u6c42\u5934\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u53ef\u4ee5\u4f7f\u7528-H\u6216--header\u9009\u9879\u6765\u8bbe\u7f6e\u8bf7\u6c42\u5934\u3002\u4f8b\u5982<strong>linux curl \u547d\u4ee4 post<\/strong>\uff0ccurl -H&#8221;Content-Type: application\/json&#8221;  \u53ef\u4ee5\u8bbe\u7f6eContent-Type\u4e3aapplication\/json\u7684\u8bf7\u6c42\u5934\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>4. Curl\u547d\u4ee4\u5982\u4f55\u5904\u7406HTTPS\u8bf7\u6c42\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>Curl\u547d\u4ee4\u9ed8\u8ba4\u652f\u6301HTTPS\u534f\u8bae\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u8bc1\u4e66\u9a8c\u8bc1\u3002\u5982\u679c\u4e0d\u9700\u8981\u9a8c\u8bc1\u8bc1\u4e66linux\u5185\u5b58\u7ba1\u7406\uff0c\u53ef\u4ee5\u4f7f\u7528-k\u6216--insecure\u9009\u9879\u7981\u7528\u8bc1\u4e66\u9a8c\u8bc1\u3002\u53e6\u5916\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528--cacert\u9009\u9879\u6307\u5b9a\u81ea\u5b9a\u4e49\u8bc1\u4e66\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>5.\u5982\u4f55\u5728Curl\u547d\u4ee4\u4e2d\u4e0a\u4f20\u6587\u4ef6\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u8981\u5728Curl\u547d\u4ee4\u4e2d\u4e0a\u4f20\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528-F\u6216--form\u9009\u9879\uff0c\u5e76\u6307\u5b9a\u8981\u4e0a\u4f20\u7684\u6587\u4ef6\u8def\u5f84\u3002\u4f8b\u5982\uff0ccurl -F&#8221;file=@\/path\/to\/file.jpg&#8221;  \u53ef\u4ee5\u4e0a\u4f20\u540d\u4e3afile.jpg\u7684\u6587\u4ef6\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>6. Curl\u547d\u4ee4\u5982\u4f55\u5904\u7406\u91cd\u5b9a\u5411\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>Curl\u547d\u4ee4\u9ed8\u8ba4\u4f1a\u81ea\u52a8\u5904\u7406\u91cd\u5b9a\u5411\uff0c\u53ef\u4ee5\u4f7f\u7528-L\u6216--location\u9009\u9879\u6765\u542f\u7528\u81ea\u52a8\u91cd\u5b9a\u5411\u3002\u53e6\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528--max-redirs\u9009\u9879\u8bbe\u7f6e\u6700\u5927\u91cd\u5b9a\u5411\u6b21\u6570\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><img style='max-height:350px;max-width:80%;margin: 10px auto' src='https:\/\/www.linuxcool.com\/wp-content\/uploads\/2023\/11\/1700251526309_1.png' alt='\u547d\u4ee4\u65b9\u5757\u6307\u4ee4_linux curl \u547d\u4ee4 post_\u547d\u4ee4\u82f1\u6587' \/><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>7.\u5982\u4f55\u5728Curl\u547d\u4ee4\u4e2d\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u53ef\u4ee5\u4f7f\u7528-m\u6216--max-time\u9009\u9879\u6765\u8bbe\u7f6e\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4\u3002\u4f8b\u5982<strong>linux curl \u547d\u4ee4 post<\/strong>\uff0ccurl -m 10  \u53ef\u4ee5\u8bbe\u7f6e\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4\u4e3a10\u79d2\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>8.\u5982\u4f55\u5728Curl\u547d\u4ee4\u4e2d\u4fdd\u5b58\u54cd\u5e94\u7ed3\u679c\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u53ef\u4ee5\u4f7f\u7528-o\u6216--output\u9009\u9879\u6765\u6307\u5b9a\u4fdd\u5b58\u54cd\u5e94\u7ed3\u679c\u7684\u6587\u4ef6\u8def\u5f84\u3002\u4f8b\u5982\uff0ccurl -o response.txt  \u53ef\u4ee5\u5c06\u54cd\u5e94\u7ed3\u679c\u4fdd\u5b58\u5230response.txt\u6587\u4ef6\u4e2d\u3002<\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'><b>9. Curl\u547d\u4ee4\u6709\u54ea\u4e9b\u5e38\u89c1\u9519\u8bef\u548c\u89e3\u51b3\u65b9\u6cd5\uff1f<\/b><\/p>\n<p style='margin-bottom:16px;color:#555555;font-size:16px;line-height:200%;text-indent:2em'>\u5e38\u89c1\u7684\u9519\u8bef\u5305\u62ec\u8fde\u63a5\u8d85\u65f6\u3001\u8bc1\u4e66\u9a8c\u8bc1\u5931\u8d25\u3001\u670d\u52a1\u5668\u8fd4\u56de\u9519\u8bef\u7b49\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\u589e\u52a0\u8d85\u65f6\u65f6\u95f4\u3001\u7981\u7528\u8bc1\u4e66\u9a8c\u8bc1\u3001\u68c0\u67e5\u670d\u52a1\u5668\u914d\u7f6e\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u53d1\u9001POST\u8bf7\u6c42\uff0c\u53ef\u4ee5\u4f7f\u7528Curl\u547d\u4ee4\u7684-d\u6216&#8211;data\u9009\u9879\uff0c\u540e\u8ddf\u8981\u53d1\u9001\u7684\u6570\u636e\u3002\u53ef\u4ee5\u5411\u53d1\u9001\u4e00\u4e2aPOST\u8bf7\u6c42\uff0c\u5e76\u5e26\u4e0a\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u53ef\u4ee5\u8bbe\u7f6eContent-Type\u4e3aapplication\/json\u7684\u8bf7\u6c42\u5934\u3002<\/p>\n","protected":false},"author":1,"featured_media":16409,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[159,428,302],"class_list":["post-16408","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge","tag-c-3","tag-p-9","tag-cdx"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/16408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=16408"}],"version-history":[{"count":0,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/16408\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media\/16409"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=16408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=16408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=16408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}