Can't access Orders using WooCommerce API -
i using woocommerce rest api library php , getting error now:
error: invalid signature - provided signature not match [woocommerce_api_authentication_error] 401 stdclass object ( [headers] => array ( [0] => accept: application/json [1] => content-type: application/json [2] => user-agent: woocommerce api client-php/2.0.1 ) [method] => [url] => http://localhost/wordpress/wc-api/v2/orders?status=completed&oauth_consumer_key=ck_b77e9a03a12d01c72b82417d2db0af68e93211d1&oauth_timestamp=1474550513&oauth_nonce=b3ca34ff55d888acaf2584812aa8ae2a0902eec3&oauth_signature_method=hmac-sha256&oauth_signature=iujvazz8v5nykfjnxj6x%2bqfwbywfycxihyj5zooy2ce%3d [params] => array ( [status] => completed [oauth_consumer_key] => ck_b77e9a03a12d01c72b82417d2db0af68e93211d1 [oauth_timestamp] => 1474550513 [oauth_nonce] => b3ca34ff55d888acaf2584812aa8ae2a0902eec3 [oauth_signature_method] => hmac-sha256 [oauth_signature] => iujvazz8v5nykfjnxj6x+qfwbywfycxihyj5zooy2ce= ) [data] => array ( [status] => completed ) [body] => [duration] => 0.73931 ) stdclass object ( [body] => {"errors":[{"code":"woocommerce_api_authentication_error","message":"invalid signature - provided signature not match"}]} [code] => 401 [headers] => array ( [date] => thu, 22 sep 2016 13:21:53 gmt [server] => apache/2.4.18 (unix) openssl/1.0.2g php/7.0.4 mod_perl/2.0.8-dev perl/v5.16.3 [x-powered-by] => php/7.0.4 [content-length] => 126 [content-type] => application/json; charset=utf-8 ) )
this code
include_once( 'api/lib/woocommerce-api.php' ); $consumer_key = 'ck_b77e9a03a12d01c72b82417d2db0af68e93211d1'; $consumer_secret = 'cs_5b96eb8bc94e63347be802c5882925a4b4e47617'; $options = array( 'debug' => true, 'return_as_array' => false, 'validate_url' => false, 'timeout' => 30, 'ssl_verify' => false, ); try { $client = new wc_api_client( 'http://localhost/wordpress', $consumer_key, $consumer_secret, $options ); $listoforders = $client->orders->get(null, array('status' => 'completed')); } catch ( wc_api_client_exception $e ) { echo $e->getmessage() . php_eol; echo $e->getcode() . php_eol; if ( $e instanceof wc_api_client_http_exception ) { print_r( $e->get_request() ); print_r( $e->get_response() ); } } echo "<pre>"; print_r($order); //print_r($listoforders); echo "</pre>";
Comments
Post a Comment