0
votes

Woocommerce update the API to version 3. Now I am unable to view or post products in the api.

This is the API docs: http://woothemes.github.io/woocommerce-rest-api-docs/#version

The documention says:

v3 deprecated the product/sku/ endpoint (because a SKU can be generated with any character, besides that there is a filter callend filter[sku]).

Though I dont know how to use that. This is my post and Im getting a invalid key and authentication issue. Though my customer key and secret is valid. copied and pasted from woocommerce. This is my post

/wc-api/v3/products/filter[E317948]?oauth_consumer_key=[]&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1439416145&oauth_nonce=KUlKZF&oauth_version=1.0&oauth_signature=LcF+sIxzuU8j83jXLziD+6K726E=

what am I doing wrong?

2

2 Answers

6
votes

I had a similar problem after upgrading to v3. My api calls were working fine on v2. I read through the authentication process in class-wc-api-authentication.php and found the difference was I needed to append an unencoded & to the consumer secret before using it to sign my parameter string.

$secret = $consumer_secret . '&';
$signature = base64_encode( hash_hmac( $hash_algorithm, $string_to_sign, $secret, true ) );
0
votes

Well I resolve my question.

Woocommercer expires the consumer_key so the only thing I have to do is generate another key and change the older to the new one.