WooCommerce REST API request returns error

2019-02-11 03:21发布

问题:

I'm developing a shopping cart Site and an App. I want to get product details from DB for my App, So I have recently used JSON REST API (WP API), And also latest version of WooCommerce 2.1.

When I run my url http://ishop/wc-api/v1/ I get a long json output, So I can make sure the API is working fine.

However when I pass a request like this:

http://ishop/wc-api/v1/products?consumer_key=ck_asd78465&consumer_secret=cs_d75412

Error:

{"errors":[{"code":"woocommerce_api_authentication_error","message":"oauth_consumer_key parameter is missing"}]}

Anything wrong in my syntax? Please help guys.

回答1:

You have to use ether HTTPS or a OAuth signature as described here: http://woothemes.github.io/woocommerce/rest-api/#authentication

There is a client library that can help you with the signature if you want to use HTTP. You can find the library here: https://github.com/kloon/WooCommerce-REST-API-Client-Library