{"id":426575,"date":"2021-04-08T06:57:51","date_gmt":"2021-04-07T22:57:51","guid":{"rendered":"http:\/\/4563.org\/?p=426575"},"modified":"2021-04-08T06:57:51","modified_gmt":"2021-04-07T22:57:51","slug":"restful-%e5%88%86%e9%a1%b5%e6%9f%a5%e8%af%a2-api-%e5%a6%82%e4%bd%95%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=426575","title":{"rendered":"RESTful \u5206\u9875\u67e5\u8be2 API \u5982\u4f55\u8bbe\u8ba1?"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  RESTful \u5206\u9875\u67e5\u8be2 API \u5982\u4f55\u8bbe\u8ba1?               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : RiceMarch <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6700\u8fd1\u5728\u5c1d\u8bd5\u5199\u4e00\u70b9\u5c0f\u4e1c\u897f\uff0c\u5728\u8bbe\u8ba1\u63a5\u53e3\u65f6\u4ea7\u751f\u4e86\u4e00\u4e9b\u7591\u60d1(\u30fb\u2200\u30fb(\u30fb\u2200\u30fb(\u30fb\u2200\u30fb*)<\/p>\n<p>\u5728 RESTful API \u4e2d\u8d44\u6e90\u7684\u83b7\u53d6\u662f GET, <\/p>\n<p>\u5047\u8bbe\u4e00\u4e2a\u573a\u666f \u9700\u8981\u8fdb\u884c\u5206\u9875\u67e5\u8be2\uff0c\u6709\u7740\u590d\u6742\u7684\u67e5\u8be2\u6761\u4ef6\u3002<\/p>\n<p>\u90a3\u4e48\u6211\u7684 uri \u5c31\u53d8\u6210\u4e86\u4e0b\u9762\u8fd9\u6837\u4e00\u957f\u4e32,\u540e\u9762\u643a\u5e26\u4e86\u4e00\u957f\u4e32\u67e5\u8be2\u6761\u4ef6<\/p>\n<pre><code>\/api\/somethings?p=2&amp;s=10&amp;q=sdasdad&amp;type=xx&amp;time=xx&amp;o=desc <\/code><\/pre>\n<p>\u4f46\u6211\u60f3\u8c61\u4e2d\u7684 restful \u662f\u8fd9\u6837\u7684\u5e05\u6c14\u6a21\u6837<\/p>\n<pre><code>\/api\/somethings\/p\/2\/s\/10 .... <\/code><\/pre>\n<p>\u6709\u60f3\u8fc7\u7528 requestbody \u628a\u67e5\u8be2\u6761\u4ef6\u8fdb\u884c\u5c01\u88c5\uff0c\u4f46\u8fd9\u660e\u663e\u4e0d\u5408\u7406\u3002<\/p>\n<p>\u597d\u5947\u5982\u4f55\u8bbe\u8ba1\u51fa\u201c\u597d\u770b\u201d\u7684 restful API \u5462\uff1f\uff08\u53ef\u80fd\u6211\u5bf9 restful \u7684\u7406\u89e3\u8fd8\u6709\u5f88\u5927\u7684\u504f\u5dee&#8230;<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>16<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5723614\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jooooooooo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c31\u662f\u4e00\u957f\u4e32\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723615\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : huijiewei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ?xxxxxxx \u5373\u53ef                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723616\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liuxey <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u8981\u5b8c\u5168\u6309\u7167 Restful \u98ce\u683c\uff0c\u90a3\u4e48\u53ef\u4ee5\u53c2\u8003\u300a RESTful Web Services Cookbook \u4e2d\u6587\u7248\u300b\u4e2d\u7684\u201c\u5982\u4f55\u8bbe\u8ba1\u96c6\u5408\u8868\u8ff0\u201d\uff0c\u4f46\u5b9e\u9645\u611f\u89c9\u5e76\u4e0d\u662f\u5f88\u65b9\u4fbf\uff0c\u5efa\u8bae \/api\/somethings\/?p=2&amp;s=10 \u4e00\u628a\u68ad                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723617\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qiayue <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             url rewrite \u53ef\u4ee5\u628a p=2&amp;s=10 \u53d8\u6210 \/p\/2\/s\/10                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723618\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : superrichman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             restful != path variable                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723619\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : YUyu101 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \/p\/2\/s\/10 \u54ea\u91cc\u597d\u770b\u4e86\uff0c\u5206\u9875\u4e0d\u5c31\u662f\u67e5\u8be2\u6761\u4ef6\u5417\uff0c\u653e\u5728\u53c2\u6570\u91cc\u5f88\u6b63\u5e38\u554a\uff0c\u6362\u4e2a\u8bf4\u6cd5\u4e0d\u5c31\u662f limit skip \u5417\uff0cget \u67e5\u8be2\u6761\u4ef6\u5acc\u957f\u8fd8\u53ef\u4ee5\u653e body \u91cc\uff0c\u53cd\u6b63 es \u662f\u8fd9\u4e48\u505a\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723620\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dzdh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148\u67e5\u8be2\u6761\u4ef6\u653e\u5230 request body \u5e76\u6ca1\u6709\u4efb\u4f55\u4e0d\u5408\u9002<\/p>\n<p>\u5176\u6b21\uff0c\u76f4\u63a5 querystring \u975e\u5e38\u5408\u9002\u3002or ?filter=jsonstring&amp;limit=xx&amp;offset=xx                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723621\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chinvo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             rest \u4e0d\u662f\u4e0d\u7528 query string.<\/p>\n<p>\u6211\u4e60\u60ef ?before=xxx&amp;size=xxx                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723622\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Kobayashi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u4e0d\u5bf9\u52b2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723623\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rationa1cuzz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e2a\u4eba\u559c\u6b22\u660e\u663e\u7b2c\u4e00\u4e2a\u597d\uff0c\u6e05\u6670\u3001\u660e\u4e86\u4e00\u770b\u5c31\u77e5\u9053\u662f\u5565\u610f\u601d\uff0c\u6055\u6211\u76f4\u8a00\uff0c\u7b2c\u4e8c\u79cd\u6211\u770b\u7684\u597d\u8822                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723624\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : aleung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6839\u636e\u5b9a\u4e49\uff0cquery string \u5c31\u662f\u653e\u67e5\u8be2\u6761\u4ef6\u7684\uff0c\u524d\u9762\u90e8\u5206\u6807\u8bc6\u7684\u662f\u8d44\u6e90\u3002\u5982\u679c\u4f60\u628a\u4e0d\u5c5e\u4e8e\u8d44\u6e90\u6807\u8bc6\u7684\u8fc7\u6ee4\u6761\u4ef6\u653e\u8fdb\u53bb\uff0c\u53cd\u800c\u4e0d\u7b26\u5408 REST \u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723625\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : unco020511 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             path variable \u5e94\u8be5\u662f id \u4e4b\u7c7b\u7684\u8d44\u6e90\u6807\u793a,\u6240\u4ee5\u4f60\u7684\u53c2\u6570\u5e94\u8be5\u6309\u7167\u662f\u5426\u5c5e\u4e8e\u8d44\u6e90\u6807\u793a\u8fd9\u6837\u7684\u6807\u51c6\u6765\u533a\u5206\u653e\u5728 path variable \u8fd8\u662f querystring,\u53e6\u5916\u6309\u7167 frc \u7684\u5efa\u8bae,get \u643a\u5e26 requestbody \u5e94\u8be5\u662f\u4e0d\u592a\u5408\u7406\u7684(\u4f46\u4e0d\u662f\u7981\u6b62).\u4ee5\u4e0a\u4e2a\u4eba\u89c1\u89e3\u4e0d\u4e00\u5b9a\u5bf9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723626\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jiaweilee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7b2c\u4e8c\u79cd\u600e\u4e48\u770b\u90fd\u5f88\u8822\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723627\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jotpot <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u4e0d\u8981\u592a\u7ea0\u7ed3\u4e86\uff0c3 \u6b63\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723628\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dddd1919 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148\u8981\u7406\u89e3 restful \u7684\u6838\u5fc3\uff1aresource\uff0c\u4e0d\u662f\u6240\u6709\u4e1c\u897f\u90fd\u662f resource\uff0c\u5c31\u50cf\u5206\u9875\u548c\u67e5\u8be2\u6761\u4ef6<br \/>\u53e6\u5916\uff0c\u4e5f\u6ca1\u8bf4\u4e0d\u8ba9\u52a0\u53c2\u6570\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5723629\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xkeyideal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             2C \u9875\u9762\u7528\u7b2c\u4e8c\u79cd\u5462\u53ef\u80fd\u4f1a\u4f18\u96c5\u6709\u70b9\uff0c\u4f46\u4f60\u8fd9\u79cd\u53c2\u6570\u592a\u591a\u4e86\u8bf4\u771f\u7684\u4e5f\u96be\u770b\u3002<br \/>\u5185\u90e8\u7cfb\u7edf\u5462\uff0c\u90a3\u4e48\u7b2c\u4e00\u79cd\u7edd\u5bf9\u662f\u7b80\u5355\u9ad8\u6548\u7684\uff0c\u4f18\u70b9\u5982\u4e0b\uff1a<br \/>1. \u4e0d\u4f1a\u51fa\u73b0\u540e\u7eed\u9700\u6c42\u8fed\u4ee3\u65f6\u51fa\u73b0\u8def\u7531\u51b2\u7a81<br \/>2. \u5bf9\u524d\u7aef\u6765\u8bf4\u4f20\u53c2\u7b80\u5355\u660e\u4e86\uff0c\u5bf9\u540e\u7aef\u7ef4\u62a4\u8d77\u6765\u4e5f\u7b80\u5355\uff0c\u53ef\u8bfb\u6027\u5f3a\uff0c<br \/>3. \u7ea6\u675f\u6027\u5f3a\uff0ckey value \u660e\u786e\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4f20\u53c2\u51fa\u9519\uff0cdebug \u534a\u5929\u540e\u53d1\u73b0\u4f20\u53c2\u9519\u4f4d\u7684 zz \u884c\u4e3a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>RESTful \u5206\u9875\u67e5\u8be2 API &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/426575"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=426575"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/426575\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426575"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}