【发布时间】:2021-03-18 20:45:09
【问题描述】:
我正在尝试关注 http://woocommerce.github.io/woocommerce-rest-api-docs/?php#list-all-order-notes 从我的订单中获取订单备注,并在嵌套的 json 响应中获取作者和 ID,但它不起作用
这里有什么明显的错误吗?
require_once 'auth.php';
$notes = $woocommerce->get('orders/108668/notes');
$json = json_decode($notes, true);
foreach($json as $elem) {
echo($elem['id']. ", ".$elem['author'] );
echo("<br/>");
}
如果我 print_r($notes); 我得到这样的回应
Array ( [0] => stdClass Object ( [id] => 24721 [author] => haspden [date_created] => 2020-12-07T09:03:01 [date_c........
如果我 print_r($json); 我什么都得不到:/
有什么想法吗?我确信这很明显,并且由于我对带有 json 的数组和对象之间的误解。
谢谢
【问题讨论】:
标签: php arrays json api woocommerce