我想使用 REST API 从 woocommerce 获取订单详细信息。如果,我尝试了任何东西,它会返回如下错误: {"code":"woocommerce_rest_cannot_view","message":"抱歉,您无法查看此资源。","data":{"status":401}}
我试过以下,
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
use Automattic\WooCommerce\HttpClient\HttpClientException;
$woocommerce = new Client(
'https://www.domain.com',
'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxXXXX',
'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
[
'version' => 'v3',
]
);
print_r($woocommerce->get('orders'));
因此,请提供任何建议或想法来实现此解决方案。提前致谢。