PHP Curl Woocommerce API的附加参数

huangapple go评论67阅读模式
英文:

PHP Curl additional parameters for Woocommerce API

问题

我能够使用默认的curl请求收集所有订单:

curl https://example.com/wp-json/wc/v3/orders -u consumer_key:consumer_secret

但我想要添加一些参数,但不确定如何添加。我尝试将其添加到URL中,但没有成功:

curl https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00 -u consumer_key:consumer_secret

我尝试使用-d '{"status":"completed"}',但似乎这会创建一个订单(即使我没有规定-X POST或PUT)。

非常感谢任何帮助。谢谢。

英文:

I'm able to collect all orders using the default curl request:

curl https://example.com/wp-json/wc/v3/orders -u consumer_key:consumer_secret

But what I want to add a couple parameters and unsure how. I have tried adding it to the url, but with no luck:

curl https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00 -u consumer_key:consumer_secret

I did try using -d '{"status":"completed"}', but this seemed to create an order (even though I have not stipulated -X POST or PUT

Any help would be greatly appreciated. Thanks

答案1

得分: 1

需要将URL放在引号内。执行curl命令如下:

curl "https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00" -u consumer_key:consumer_secret
英文:

You'll need to wrap the URL inside quotes. Execute the curl command like this:

curl "https://example.com/wp-json/wc/v3/orders?status=completed&after=2023-06-01T00:00:00-00:00" -u consumer_key:consumer_secret

huangapple
  • 本文由 发表于 2023年6月8日 22:44:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433037.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定