BigCommerce API调用-获取订单


BigCommerce API Call - Get Orders

我试图在BigCommerce中做一个简单的API调用。我从这些链接中得到了一些信息:

获取订单计数

BigCommerce API快速入门

我试过订单。json和订单/计数,但我没有得到任何响应。我一定错过了一些简单的东西。我一定要以某种方式回应吗?

这是我的代码。

<?php
curl --request GET '
  -u "username:key" '
  https://store.com/api/v2/orders/count;
?>

我收到了BigCommerce的回复,没有任何帮助。

我在"如何在php curl中使用基本授权","JSON到php使用json_decode"answers"JSON"的帮助下弄清楚了这一点。

我在GoDaddy托管服务器上运行PHP 5.6.22和curl 7.36.0,在. PHP文件中运行这段代码。

<?php
$username = "Username";
$password = "API Token";
$URL = "https://store.com/api/v2/orders/count.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //Timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //Get status code
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response);
echo "Count = " . $result->count; //Total orders
echo "<br />" . $result->statuses[8]->name . " = " . $result->statuses[8]->count; //Shipped orders
?>