[我尝试使用WooCommerce rest api来获取并获得所有产品,但是当json数据返回时,它添加了新产品并仅返回名为"product"
的新产品作为名称。
这是我的代码
define("TOKEN_API" , "eyJ0eXAiOiJKL1QiLCJhbGciOaJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9xd3cuaGFtaXRhay5jb20iLCJpYXQiOjE1ODcyMjUzNTQsIm5iZiI6MTU4NzIyNTM1NCwiZXhwIjoxNTg3ODMwMTU0LCJkYXRhIj17InVzZXIiOnsiaWQi1iI3In19fQ.9AhzaFJLX1B-x0KEwA0CH14v-5IaiEyEhCA-5sTeSQ8");
$url = "http://www.example.com" . "/wp-json/wc/v2/products";
$authorization = "Authorization: Bearer " . TOKEN_API;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
$products = json_decode($server_output , true);
print_r($products);
是什么问题。我搜索了很多但没有找到。
我终于找到了这是因为发布请求我现在使用get request及其罚款