我已经集成了 Shopify Order API。参考链接
当前正在根据created_at_min
字段获取订单。我每隔 10 分钟调用一次 API,就像上次 API 在上午 11:00 调用一样,因此下一个 API 将获取在上午 11:00 之后创建的订单,脚本将保留当前 API 调用的时间。
时区也基于 shopify 时区在我的脚本代码中设置。
问题是,如果在上午 11:00 创建的订单,而我试图获取在上午 11:20 之后创建的订单,仍然是上午 11:00 创建的订单即将到来。
调用订单 API 的理想时间间隔应该是多少?
我的代码如下:
$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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句