首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BigCommerce接口调用-获取订单

BigCommerce接口调用-获取订单
EN

Stack Overflow用户
提问于 2016-08-15 14:40:27
回答 1查看 910关注 0票数 2

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

Get a Count of Orders

BigCommerce API Quickstarts

我尝试了orders.json和orders/count,但没有得到任何响应。我一定漏掉了一些简单的东西。我一定要以某种方式回应这个回答吗?

这是我的代码。

代码语言:javascript
复制
<?php

curl --request GET \
  -u "username:key" \
  https://store.com/api/v2/orders/count;

?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-17 15:47:02

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

我在"how to use basic authorization in php curl“、"JSON to PHP Using json_decode”和"JSON“的帮助下弄明白了这一点。

我在运行PHP5.6.22和curl 7.36.0的GoDaddy托管服务器上的.php文件中运行了这段代码。

代码语言:javascript
复制
<?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

?>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38950396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档