{"id":123093,"date":"2026-11-06T11:32:58","date_gmt":"2026-11-06T03:32:58","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123093.html"},"modified":"2026-11-06T11:32:58","modified_gmt":"2026-11-06T03:32:58","slug":"api%e6%8e%a5%e5%8f%a3%e6%80%8e%e4%b9%88%e5%af%b9%e6%8e%a5%e6%89%8d%e7%a8%b3%ef%bc%9f%e6%88%91%e6%8a%8a%e8%b6%85%e6%97%b6%e3%80%81%e9%87%8d%e8%af%95%e5%92%8c%e4%b8%89%e5%ae%b6%e4%ba%91%e7%ad%be","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123093.html","title":{"rendered":"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u73af\u5883\u8bf4\u660e&#xff1a;\u672c\u673a Windows 10 22H2 &#043; Python 3.13.12&#xff0c;\u4e0b\u6587\u6240\u6709\u8fd4\u56de\u4e0e\u62a5\u9519\u5747\u7528\u6807\u51c6\u5e93 urllib \u76f4\u8fde\u4e00\u4e2a\u672c\u5730 mock \u670d\u52a1&#xff08;127.0.0.1:8811&#xff09;\u8dd1\u51fa&#xff0c;\u4e0d\u4f9d\u8d56\u5916\u7f51&#xff1b;\u4e09\u5bb6\u4e91\u7684\u7b7e\u540d\u7ed3\u8bba\u6765\u81ea\u5404\u81ea\u5b98\u65b9\u6587\u6863&#xff0c;\u672a\u9010\u9879\u5b9e\u8dd1\u7b7e\u540d\u8ba1\u7b97\u3002<\/p>\n<p>\u4f60\u63a5\u8fc7\u7684\u63a5\u53e3\u5927\u6982\u5206\u4e09\u7c7b&#xff1a;\u7b2c\u4e09\u65b9\u652f\u4ed8\u3001\u4e91\u5382\u5546\u7684 OpenAPI\u3001\u516c\u53f8\u5185\u90e8\u670d\u52a1\u3002\u65b0\u624b\u5e38\u4ee5\u4e3a api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5 \u5c31\u662f\u628a URL \u62fc\u597d\u3001\u53c2\u6570\u585e\u8fdb\u53bb\u3001\u7b49\u8fd4\u56de\u3002\u6211\u8e29\u8fc7\u7684\u5751\u544a\u8bc9\u6211&#xff0c;\u96be\u7684\u5730\u65b9\u4e0d\u5728&#034;\u8c03\u901a\u4e00\u6b21&#034;&#xff0c;\u800c\u5728&#034;\u751f\u4ea7\u73af\u5883\u91cc\u5b83\u9694\u4e09\u5dee\u4e94\u4ee5\u4f60\u6ca1\u60f3\u8fc7\u7684\u65b9\u5f0f\u6302\u6389&#034;\u3002\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u7528 Python \u5b9e\u8dd1\u4e86\u4e00\u904d&#xff0c;\u4e0b\u9762\u628a\u8bc1\u636e\u548c\u6392\u6cd5\u644a\u5f00\u3002<\/p>\n<p>\u52a8\u624b\u524d\u5148\u5206\u4e00\u4ef6\u4e8b&#xff1a;\u4f60\u8981\u7684\u662f&#034;\u80fd\u8c03\u901a&#034;&#xff0c;\u8fd8\u662f&#034;\u8c03\u5f97\u7a33&#034;\u3002\u80fd\u8c03\u901a\u53ea\u8981\u4e00\u6b21 200&#xff1b;\u8c03\u5f97\u7a33\u8981\u5904\u7406\u8fde\u63a5\u62d2\u7edd\u3001\u8d85\u65f6\u30015xx\u3001\u91cd\u590d\u63d0\u4ea4\u3001\u65f6\u949f\u504f\u79fb\u3002\u672c\u6587\u8bb2\u7684\u662f\u540e\u8005\u2014\u2014\u4e00\u6b21\u6027\u7684\u8054\u8c03\u811a\u672c\u4e0d\u5728\u8ba8\u8bba\u8303\u56f4\u3002<\/p>\n<h3>\u8fde\u63a5\u5c42&#xff1a;\u8bf7\u6c42\u5230\u5e95\u6709\u6ca1\u6709\u771f\u6b63\u51fa\u53bb<\/h3>\n<p>\u5f88\u591a\u4eba\u770b\u5230\u62a5\u9519\u5148\u6000\u7591\u53c2\u6570&#xff0c;\u5176\u5b9e\u5148\u786e\u8ba4\u8bf7\u6c42\u6709\u6ca1\u6709\u62b5\u8fbe\u5bf9\u7aef\u3002\u804a\u5230 api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5&#xff0c;\u5148\u786e\u8ba4\u8bf7\u6c42\u6709\u6ca1\u6709\u771f\u6b63\u51fa\u53bb&#xff0c;\u6bd4\u6539\u53c2\u6570\u66f4\u9760\u524d\u3002\u6211\u8d77\u4e86\u4e00\u4e2a\u672c\u5730 mock \u670d\u52a1&#xff0c;\u7aef\u53e3 8811&#xff0c;\u5206\u522b\u6253\u4e86\u6b63\u5e38\u63a5\u53e3\u3001\u4e0d\u5b58\u5728\u8def\u5f84\u3001\u548c\u4e00\u4e2a\u6839\u672c\u6ca1\u5f00\u670d\u52a1\u7684\u7aef\u53e3\u3002<\/p>\n<p><span class=\"token keyword\">import<\/span> json<span class=\"token punctuation\">,<\/span> urllib<span class=\"token punctuation\">.<\/span>request<span class=\"token punctuation\">,<\/span> urllib<span class=\"token punctuation\">.<\/span>error<span class=\"token punctuation\">,<\/span> socket<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">call<\/span><span class=\"token punctuation\">(<\/span>url<span class=\"token punctuation\">,<\/span> timeout<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    req <span class=\"token operator\">&#061;<\/span> urllib<span class=\"token punctuation\">.<\/span>request<span class=\"token punctuation\">.<\/span>Request<span class=\"token punctuation\">(<\/span>url<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">with<\/span> urllib<span class=\"token punctuation\">.<\/span>request<span class=\"token punctuation\">.<\/span>urlopen<span class=\"token punctuation\">(<\/span>req<span class=\"token punctuation\">,<\/span> timeout<span class=\"token operator\">&#061;<\/span>timeout<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> r<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> r<span class=\"token punctuation\">.<\/span>status<span class=\"token punctuation\">,<\/span> json<span class=\"token punctuation\">.<\/span>loads<span class=\"token punctuation\">(<\/span>r<span class=\"token punctuation\">.<\/span>read<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">except<\/span> urllib<span class=\"token punctuation\">.<\/span>error<span class=\"token punctuation\">.<\/span>HTTPError <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> e<span class=\"token punctuation\">.<\/span>code<span class=\"token punctuation\">,<\/span> e<span class=\"token punctuation\">.<\/span>reason<br \/>\n    <span class=\"token keyword\">except<\/span> <span class=\"token punctuation\">(<\/span>urllib<span class=\"token punctuation\">.<\/span>error<span class=\"token punctuation\">.<\/span>URLError<span class=\"token punctuation\">,<\/span> TimeoutError<span class=\"token punctuation\">,<\/span> socket<span class=\"token punctuation\">.<\/span>timeout<span class=\"token punctuation\">,<\/span> ConnectionError<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span><span class=\"token builtin\">getattr<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;reason&#034;<\/span><span class=\"token punctuation\">,<\/span> e<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u4e09\u4e2a\u8fd4\u56de\u662f\u5b9e\u8dd1\u51fa\u6765\u7684&#xff1a;<\/p>\n<p>\u6b63\u5e38 200   -&gt; (200, {&#039;order_id&#039;: &#039;20261104-0088&#039;, &#039;status&#039;: &#039;paid&#039;, &#039;amount&#039;: 99.0})<br \/>\n\u8def\u5f84\u4e0d\u5b58\u5728 -&gt; (404, &#039;Not Found&#039;)<br \/>\n\u8fde\u5230\u65e0\u670d\u52a1\u7aef\u53e3 127.0.0.1:9 -&gt; (None, &#039;[WinError 10061] \u7531\u4e8e\u76ee\u6807\u8ba1\u7b97\u673a\u79ef\u6781\u62d2\u7edd&#xff0c;\u65e0\u6cd5\u8fde\u63a5\u3002&#039;)<\/p>\n<p>\u6ce8\u610f 404 \u548c\u8fde\u63a5\u62d2\u7edd\u662f\u4e24\u7801\u4e8b&#xff1a;404 \u8bf4\u660e TCP \u5df2\u7ecf\u5efa\u7acb\u3001\u5bf9\u7aef\u6b63\u5e38\u56de\u4e86&#034;\u6ca1\u8fd9\u8d44\u6e90&#034;&#xff1b;\u8fde\u63a5\u62d2\u7edd\u8bf4\u660e\u5bf9\u7aef\u7aef\u53e3\u6839\u672c\u6ca1\u76d1\u542c&#xff0c;\u8fde\u63e1\u624b\u90fd\u6ca1\u5f00\u59cb\u3002\u6211\u6392\u67e5\u65f6\u5148\u770b\u72b6\u6001\u7801\u5c5e\u4e8e\u54ea\u4e00\u7c7b&#xff0c;\u518d\u51b3\u5b9a\u662f\u6539 URL\u3001\u67e5\u7f51\u7edc\u8fd8\u662f\u67e5\u670d\u52a1\u662f\u5426\u5b58\u6d3b\u3002<\/p>\n<h3>\u8d85\u65f6\u4e0e\u91cd\u8bd5&#xff1a;timeout \u4e0d\u662f\u53ef\u9009\u9879<\/h3>\n<p>\u9ed8\u8ba4\u4e0d\u8bbe\u8fd9\u4e2a\u53c2\u6570&#xff0c;\u5e93\u4f1a\u4e00\u76f4\u7b49&#xff0c;\u7ebf\u7a0b\u5c31\u540a\u6b7b\u5728\u90a3\u3002\u6211\u7279\u610f\u628a\u4e00\u4e2a\u63a5\u53e3\u6539\u6210 sleep 3 \u79d2&#xff0c;\u518d\u7528 timeout&#061;1 \u53bb\u6253&#xff1a;<\/p>\n<p>timeout&#061;1 \u6253 sleep 3 \u7684\u63a5\u53e3 -&gt; (None, &#039;timed out&#039;)<\/p>\n<p>\u5230\u8fd9\u91cc\u53ea\u662f&#034;\u4e0d\u5361\u6b7b&#034;&#xff0c;\u8fd8\u6ca1&#034;\u6253\u5f97\u901a&#034;\u30025xx \u662f\u53e6\u4e00\u7c7b&#xff1a;\u670d\u52a1\u6d3b\u7740\u4f46\u4e34\u65f6\u4e0d\u53ef\u7528\u3002\u6211\u8ba9 \/api\/flaky \u524d\u4e24\u6b21\u8fd4\u56de 503\u3001\u7b2c\u4e09\u6b21\u8fd4\u56de 200&#xff0c;\u8dd1\u4e00\u4e2a\u5e26\u9000\u907f\u7684\u91cd\u8bd5&#xff1a;<\/p>\n<p>\u7b2c1\u6b21 -&gt; code&#061;503 body&#061;Service Unavailable<br \/>\n\u7b2c2\u6b21 -&gt; code&#061;503 body&#061;Service Unavailable<br \/>\n\u7b2c3\u6b21 -&gt; code&#061;200 body&#061;{&#039;ok&#039;: True, &#039;attempt&#039;: 3}<\/p>\n<p>\u91cd\u8bd5\u6709\u4e24\u4e2a\u5751\u6211\u5fc5\u987b\u63d0\u9192&#xff1a;\u4e00\u662f\u53ea\u5728 5xx \u548c\u8d85\u65f6\u8fd9\u7c7b&#034;\u53ef\u80fd\u81ea\u6108&#034;\u7684\u9519\u8bef\u4e0a\u91cd\u8bd5&#xff0c;4xx&#xff08;\u542b 404&#xff09;\u91cd\u8bd5\u6ca1\u610f\u4e49&#xff1b;\u4e8c\u662f\u9000\u907f\u8981\u53e0\u52a0\u6296\u52a8&#xff0c;\u522b\u8ba9\u4e00\u5806\u5ba2\u6237\u7aef\u540c\u4e00\u79d2\u540c\u65f6\u91cd\u8fde\u628a\u5bf9\u7aef\u6253\u6302\u3002\u91cd\u8bd5\u6b21\u6570\u6211\u4e00\u822c\u538b\u5728 3 \u6b21\u4ee5\u5185\u3002<\/p>\n<h3>\u9274\u6743\u4e0e\u7b7e\u540d&#xff1a;\u4e09\u5bb6\u4e91\u600e\u4e48\u53d1\u8bf7\u6c42<\/h3>\n<p>\u518d\u8bf4 api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5 \u7684\u4e00\u4e2a\u5ef6\u4f38\u573a\u666f&#xff1a;\u4e91\u5382\u5546 OpenAPI&#xff0c;\u96be\u7684\u662f\u7b7e\u540d&#xff0c;\u4e0d\u662f\u8bf7\u6c42\u672c\u8eab\u3002\u6211\u628a\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\u3001\u534e\u4e3a\u4e91\u7684\u7b7e\u540d\u6587\u6863\u90fd\u7ffb\u4e86\u4e00\u904d&#xff0c;\u673a\u5236\u5b8c\u5168\u4e0d\u540c&#xff0c;\u4e0d\u80fd\u5957\u4e00\u5957\u4ee3\u7801\u6253\u4e09\u5bb6\u3002<\/p>\n<table>\n<tr>\u5382\u5546\u7b7e\u540d\u7b97\u6cd5\u5173\u952e\u8f7d\u4f53\u6587\u6863\u5165\u53e3<\/tr>\n<tbody>\n<tr>\n<td>\u963f\u91cc\u4e91<\/td>\n<td>HMAC-SHA1 \/ HMAC-SHA256&#xff08;RPC \u98ce\u683c&#xff09;<\/td>\n<td>AccessKey &#043; \u89c4\u8303\u67e5\u8be2\u4e32<\/td>\n<td>\u963f\u91cc\u4e91 SDK \u6587\u6863<\/td>\n<\/tr>\n<tr>\n<td>\u817e\u8baf\u4e91<\/td>\n<td>TC3-HMAC-SHA256<\/td>\n<td>SecretId\/SecretKey &#043; \u89c4\u8303\u8bf7\u6c42\u4e32<\/td>\n<td>\u817e\u8baf\u4e91 \u7b7e\u540d\u65b9\u6cd5 v3<\/td>\n<\/tr>\n<tr>\n<td>\u534e\u4e3a\u4e91<\/td>\n<td>SDK-HMAC-SHA256<\/td>\n<td>AK\/SK &#043; X-Sdk-Date \u5934<\/td>\n<td>\u534e\u4e3a\u4e91 API \u7b7e\u540d\u6307\u5357<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e09\u5bb6\u5171\u540c\u70b9\u662f\u90fd\u7528 AK\/SK \u505a HMAC&#xff0c;\u4f46\u62fc\u4e32\u89c4\u5219\u548c\u5934\u5b57\u6bb5\u5404\u5199\u5404\u7684&#xff1b;\u534e\u4e3a\u4e91\u8fd8\u989d\u5916\u8981\u6c42\u672c\u5730\u65f6\u949f\u548c\u670d\u52a1\u5668\u8bef\u5dee\u4e0d\u8d85\u8fc7 15 \u5206\u949f&#xff0c;\u5426\u5219\u76f4\u63a5\u62d2\u3002\u6807\u51c6\u5e93\u7684\u8c03\u7528\u5199\u6cd5\u89c1 Python urllib \u6587\u6863\u3002\u6211\u7684\u5efa\u8bae\u662f\u522b\u624b\u6413&#xff0c;\u76f4\u63a5\u7528\u5404\u5bb6 SDK\u3002<\/p>\n<h3>\u6392\u67e5\u6e05\u5355&#xff1a;\u63a5\u53e3\u6302\u4e86\u6309\u8fd9\u4e2a\u987a\u5e8f\u770b<\/h3>\n<li>\u7f51\u7edc\u5c42&#xff1a;\u57df\u540d\u80fd\u5426\u89e3\u6790\u3001\u7aef\u53e3\u662f\u5426\u901a&#xff08;\u8fde\u63a5\u62d2\u7edd\u5148\u67e5\u8fd9\u91cc&#xff09;\u3002<\/li>\n<li>\u8d85\u65f6\u5c42&#xff1a;timeout \u662f\u5426\u8bbe\u4e86&#xff0c;\u503c\u662f\u5426\u5408\u7406\u3002<\/li>\n<li>\u534f\u8bae\u5c42&#xff1a;HTTPS \u8bc1\u4e66\u3001HTTP \u65b9\u6cd5\u3001Content-Type \u662f\u5426\u5bf9\u5f97\u4e0a\u3002<\/li>\n<li>\u4e1a\u52a1\u5c42&#xff1a;\u72b6\u6001\u7801\u662f 4xx&#xff08;\u8bf7\u6c42\u6709\u95ee\u9898&#xff09;\u8fd8\u662f 5xx&#xff08;\u5bf9\u7aef\u6709\u95ee\u9898&#xff09;\u3002<\/li>\n<li>\u5e42\u7b49\u5c42&#xff1a;\u91cd\u8bd5\u4f1a\u4e0d\u4f1a\u9020\u6210\u91cd\u590d\u4e0b\u5355\u3001\u91cd\u590d\u6263\u6b3e\u3002<\/li>\n<p>\u6211\u6bcf\u6b21\u8054\u8c03\u90fd\u6309\u4e0a\u9762\u7684\u987a\u5e8f\u8d70&#xff0c;\u7701\u6389\u4e00\u534a\u778e\u731c\u3002<\/p>\n<h3>\u53cd\u5411\u8fb9\u754c&#xff1a;\u4ec0\u4e48\u65f6\u5019\u4e0d\u8be5\u81ea\u5df1\u9020\u8f6e\u5b50<\/h3>\n<p>\u4e0d\u7ba1 api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5 \u843d\u5230\u54ea\u79cd\u573a\u666f&#xff0c;\u751f\u4ea7\u7ea7\u90fd\u522b\u7701\u6389\u8d85\u65f6\u548c\u91cd\u8bd5\u3002\u4f46\u4e0d\u662f\u6240\u6709\u63a5\u53e3\u90fd\u503c\u5f97\u624b\u5199 HTTP \u5ba2\u6237\u7aef&#xff0c;\u4e0b\u9762\u51e0\u79cd\u60c5\u51b5\u6211\u76f4\u63a5\u4e0a SDK \u6216\u7f51\u5173&#xff1a;<\/p>\n<ul>\n<li>\u8981\u8c03\u4e91\u5382\u5546 OpenAPI&#xff1a;\u7b7e\u540d\u89c4\u5219\u968f\u7248\u672c\u53d8&#xff0c;\u624b\u6413\u8fdf\u65e9\u8e29\u5751&#xff0c;\u7528\u5b98\u65b9 SDK\u3002<\/li>\n<li>\u8981\u5bf9\u63a5\u591a\u5bb6\u3001\u4e14\u8981\u9650\u6d41\u7194\u65ad&#xff1a;\u4e0a API \u7f51\u5173\u6216\u73b0\u6210\u7684\u5ba2\u6237\u7aef\u5e93&#xff0c;\u522b\u81ea\u5df1\u5806 if\u3002<\/li>\n<li>\u53ea\u662f\u5185\u90e8\u670d\u52a1\u4e92\u8c03&#xff1a;\u6846\u67b6\u81ea\u5e26\u7684 HTTP \u5ba2\u6237\u7aef\u901a\u5e38\u591f\u7528&#xff0c;\u6ca1\u5fc5\u8981\u5f15\u7b2c\u4e09\u65b9\u3002<\/li>\n<\/ul>\n<p>\u53cd\u8fc7\u6765&#xff0c;\u5355\u6b21\u3001\u4f4e\u9891\u3001\u5bf9\u65b9\u662f\u7b80\u5355 JSON \u63a5\u53e3\u65f6&#xff0c;\u6807\u51c6\u5e93 urllib \u8db3\u591f&#xff0c;\u5f15 requests \u53cd\u800c\u591a\u4e00\u4e2a\u4f9d\u8d56\u3002<\/p>\n<h3>FAQ<\/h3>\n<p>\u5bf9\u63a5\u7b2c\u4e09\u65b9\u63a5\u53e3\u8981\u4ece\u54ea\u4e00\u6b65\u5f00\u59cb&#xff1f; \u5148\u786e\u8ba4\u5bf9\u65b9\u7ed9\u7684\u662f REST \u8fd8\u662f RPC\u3001\u9274\u6743\u662f Header \u4ee4\u724c\u8fd8\u662f\u7b7e\u540d&#xff1b;\u8054\u8c03\u7528 200 \u8dd1\u901a\u540e&#xff0c;\u518d\u8865\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u9519\u8bef\u5206\u7c7b&#xff0c;\u522b\u4e00\u6b65\u5230\u4f4d\u5199\u751f\u4ea7\u4ee3\u7801\u3002<\/p>\n<p>\u63a5\u53e3\u8fd4\u56de 503 \u8981\u91cd\u8bd5\u5417&#xff1f; \u8981&#xff0c;\u4f46\u53ea\u5728 5xx \u548c\u8d85\u65f6\u4e0a\u91cd\u8bd5&#xff0c;\u914d\u5408\u9000\u907f\u4e0e\u6296\u52a8&#xff0c;\u6b21\u6570\u538b\u5728 3 \u6b21\u4ee5\u5185&#xff1b;404 \u8fd9\u7c7b 4xx \u4e0d\u8981\u91cd\u8bd5\u3002<\/p>\n<p>timeout \u8bbe\u591a\u5c11\u5408\u9002&#xff1f; \u6ca1\u6709\u7edf\u4e00\u503c&#xff0c;\u770b\u5bf9\u7aef P99 \u5ef6\u8fdf\u3002\u6211\u4e60\u60ef\u8bbe\u6210\u5bf9\u7aef\u6b63\u5e38\u54cd\u5e94\u65f6\u95f4\u7684 2 \u5230 3 \u500d&#xff0c;\u5e76\u7ed9\u8fde\u63a5\u8d85\u65f6\u548c\u8bfb\u53d6\u8d85\u65f6\u5206\u522b\u8bbe\u503c&#xff0c;\u800c\u4e0d\u662f\u5171\u7528\u4e00\u4e2a\u3002<\/p>\n<p>\u4e09\u5bb6\u4e91\u7684 API \u7b7e\u540d\u80fd\u901a\u7528\u5417&#xff1f; \u4e0d\u80fd\u3002\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\u3001\u534e\u4e3a\u4e91\u7b97\u6cd5\u548c\u5934\u5b57\u6bb5\u90fd\u4e0d\u540c&#xff0c;\u5404\u5bb6\u7684 SDK \u4e5f\u4e0d\u4e92\u901a&#xff0c;\u6309\u5382\u5546\u5206\u522b\u63a5\u5165\u3002<\/p>\n<h3>\u7ed3\u5c3e<\/h3>\n<p>\u56de\u5230\u5f00\u5934&#xff1a;api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5&#xff0c;\u8c03\u901a\u53ea\u662f\u8d77\u70b9\u3002\u8fde\u63a5\u62d2\u7edd\u3001\u8d85\u65f6\u30015xx\u3001\u91cd\u590d\u63d0\u4ea4&#xff0c;\u8fd9\u56db\u4ef6\u4e8b\u6309\u987a\u5e8f\u6392\u2014\u2014\u5148\u770b\u7f51\u7edc&#xff0c;\u518d\u770b\u8d85\u65f6&#xff0c;\u518d\u770b\u534f\u8bae&#xff0c;\u6536\u5c3e\u770b\u5e42\u7b49\u3002\u751f\u4ea7\u7ea7\u7684\u5bf9\u63a5&#xff0c;\u810f\u6d3b\u4ea4\u7ed9 SDK&#xff0c;\u6211\u81ea\u5df1\u53ea\u76ef\u4f4f\u91cd\u8bd5\u8fb9\u754c\u548c\u65f6\u949f\u504f\u79fb\u8fd9\u4e24\u5904\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[230,190],"topic":[],"class_list":["post-123093","post","type-post","status-publish","format-standard","hentry","category-server","tag-php","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/123093.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123093.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-06T03:32:58+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123093.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123093.html\",\"name\":\"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-06T03:32:58+00:00\",\"dateModified\":\"2026-11-06T03:32:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123093.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123093.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123093.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/123093.html","og_locale":"zh_CN","og_type":"article","og_title":"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/123093.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-06T03:32:58+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123093.html","url":"https:\/\/www.wsisp.com\/helps\/123093.html","name":"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-06T03:32:58+00:00","dateModified":"2026-11-06T03:32:58+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123093.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123093.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123093.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"api\u63a5\u53e3\u600e\u4e48\u5bf9\u63a5\u624d\u7a33\uff1f\u6211\u628a\u8d85\u65f6\u3001\u91cd\u8bd5\u548c\u4e09\u5bb6\u4e91\u7b7e\u540d\u8fd9\u4e09\u9053\u5173\u8dd1\u4e86\u4e00\u904d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=123093"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123093\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123093"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}