WooCommerce REST API - 使用after/before参数获取订单

use*_*124 3 wordpress woocommerce woocommerce-rest-api

我正在使用WooCommerce REST API(http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction),并且能够成功下载客户,订单等.我现在只想下载两个日期之间的订单列表 - 我可以在Orders的文档中看到以下参数:

after   string  Limit response to resources published after a given ISO8601 compliant date.
before  string  Limit response to resources published before a given ISO8601 compliant date.
Run Code Online (Sandbox Code Playgroud)

我已将请求的URL修改为:

https://mywebsite.com/wp-json/wc/v1/orders?after=2016-08-05&before=2016-08-06&page=1
Run Code Online (Sandbox Code Playgroud)

但是这个回复我得到400错误:

{
  "code": "rest_invalid_param", 
  "data": {
    "params": {
      "after": "The date you provided is invalid.", 
      "before": "The date you provided is invalid."
    }, 
    "status": 400
  }, 
  "message": "Invalid parameter(s): after, before"
}
Run Code Online (Sandbox Code Playgroud)

据我所知,这两个日期是符合ISO8601标准的有效日期.无法找到此请求应如何显示的示例,因此不确定从何处开始.

use*_*124 6

事实证明你还需要指定时间,例如

after=2016-11-20T13:57:31.2311892-04:00
Run Code Online (Sandbox Code Playgroud)

  • 您可以使其在正时区(例如+01:00)下工作吗? (2认同)