Ecommerce Shopify WordPress Discussion

WooCommerce – Invalid signature – provided signature does not match when passing "after" parameter

Solved it: Looks like "after" was supposed to be passed in $parameters and in the query too, but not encoded. foreach ($parameters as $key => $value) { $encodedParams[rawurlencode($key)] = $key == "after" ? $value : rawurlencode($value); } After doing above the filter now works. below is the code I am using to fetch orders from WooCommerce. I did it as described in the documentation and it works perfectly fine. However, I am trying to get orders which are created only after certain date but when I try to pass in "after" parameter I get 401 Error saying "Invalid signature - provided signature does not match.". I don't understand how should I pass in the "after" parameter and generate signature so it works. Also, if there's better way of generating the signature, please let me know! I appreciate any help provided. $http_method = "GET"; $request_url = "http://myurl.com/wp-json/wc/v3/orders"; $parameters = [ "oauth_consumer_key" => "ck_example", "oauth_timestamp" => time(), "oauth_nonce" => md5(mt_rand()), "oauth_signature_method" => "HMAC-SHA1", "oauth_version" => "1.0", ]; $encodedParams = []; foreach ($parameters as $key => $value) { $encodedParams[rawurlencode($key)] = rawurlencode($value); } uksort($encodedParams, "strcmp"); $base = strtoupper($http_method) . "&" . rawurlencode($request_url) . "&" . rawurlencode(http_build_query($encodedParams)); $key = rawurlencode("cs_example") . "&"; $signature = base64_encode(hash_hmac("sha1", $base, $key, true)); $encodedParams["signature"] = $signature; $header = "OAuth oauth_consumer_key=\"{$encodedParams["oauth_consumer_key"]}\",oauth_signature_method=\"{$encodedParams["oauth_signature_method"]}\",oauth_timestamp=\"{$encodedParams["oauth_timestamp"]}\",oauth_nonce=\"{$encodedParams["oauth_nonce"]}\",oauth_version=\"{$encodedParams["oauth_version"]}\",oauth_signature=\"{$encodedParams["signature"]}\""; $response = Http::withHeaders([ "Authorization" => $header, "Content-Type" => "application/json" ])->get($request_url); $response->json(); I tried passing it as a parameter in $parameters array and/or passing it as a query parameter in get() but it doesn't seem to do the trick. Also, tried including it in the $request_url and adding it to parameters as well but I still get Invalid Signature 401 Error. Update: If I do it like below I get Invalid Signature error but if I pass in ["after" => $encodedParams["after"]] in query I get "Invalid parameter(s): after". $parameters = [ "oauth_consumer_key" => "", "oauth_timestamp" => time(), "oauth_nonce" => md5(mt_rand()), "oauth_signature_method" => "HMAC-SHA1", "oauth_version" => "1.0", "after" => "2024-01-10 09:45:17" ]; ... $response = Http::withHeaders([ "Authorization" => $header, "Content-Type" => "application/json" ])->get($request_url, ["after" => $parameters["after"]]);
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.