我已经集成了Shopify Order API。参考链接
当前基于created_at_min字段的订单获取。我每隔10分钟调用一次API,就像在上午11:00调用最后一个API一样,所以下一个API将获取顺序,不管是在11:00 am之后创建的,脚本将保持当前API调用的时间。
时区也是基于shopify时区在我的脚本代码中设置的。
问题是如果在上午11:00创建的订单,而我正在尝试获取在11:20之后创建的订单,那么11:00创建的订单就会出现。
调用order的理想时间间隔应该是什么?
我的代码如下:
$lastScriptRun = $this->selectLastRun(); // Fetching last run time from database
// Here creating current time to store in database
$estDate = new DateTime( date("Y-m-d h:i:s") , new DateTimeZone('UTC'));
$estDate->setTimezone(new DateTimeZone('US/Pacific'));
$scriptStart = $estDate->format('c');
// Fetching orders
$orders = $shopify->Order->get( array('status' => 'any', 'created_at_min' => $lastScriptRun) );
....... // [after some code]
// Updating last API call time into database
$this->updateLastRun($scriptStart);发布于 2018-11-20 11:20:19
我找到了解决办法。
这一行没有正确返回UTC时间。
$estDate = new DateTime( date("Y-m-d h:i:s") , new DateTimeZone('UTC'));我尝试了另一个在定义和解决方案链接中找到的链接。
$estDate = new DateTime( gmdate("Y-m-d\T00:00:00\Z") );解决方案:理想的时间可以是任何时间(调用为我的应用程序设置的API的标准30分钟)。
https://stackoverflow.com/questions/53340281
复制相似问题