【发布时间】:2015-03-12 00:21:18
【问题描述】:
我正在为我的同事开发一个 Web 应用程序,因此他们将拥有一台带有应用程序的 iPad,以打包我们的订单。
整个应用程序即将完成,最后的步骤之一是将订单状态从处理中更改为完成。
我在做什么:
获取当前订单 ID,然后使用 curl 或 API 更改状态。发生的事情很奇怪,我得到了 JSON 数据,并且更新了 completed_at 时间,但状态仍在处理中。
下面你会看到我的代码:
$data = array("status" => "completed");
$data_string = json_encode($data);
$username = 'XXX'; // Add your own Consumer Key here
$password = 'XXX'; // Add your own Consumer Secret here
$ch = curl_init('https://www.deallerleukste.nl/wc-api/v2/orders/5764?consumer_key='.$username.'&consumer_secret='.$password);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
echo $result;
有人看到我做错了吗?请帮忙!
问候,
杰尔默
【问题讨论】:
标签: php wordpress api curl woocommerce