Reputation:
I am trying to Upload the Product to Woo commerce Store but on upload it gives me the below Error code am not sure where am going Wrong.
and I am note Sure on one Case to Should i have to include any Lib to make work if help me on that
FYI: this is a V3 API code of woocommerce
Error Code
{"errors":[{"code":"woocommerce_api_authentication_error","message":"oauth_consumer_key parameter is missing"}]}
My Code
$aData = array(
'product' => array(
'title' => 'Premium Quality',
'type' => 'simple'
)
);
$sData = json_encode($aData);
$ch = curl_init('http://example.com/demo/ir/wc-api/v3/products');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $sData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, 'ck_xxxxxxxxxxxxxxxxxx:cs_xxxxxxxxxxxxxxxxxxx');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($sData))
);
$result = curl_exec($ch);
print_r($result);
Upvotes: 2
Views: 968
Reputation: 375
I am using kloon-WooCommerce-REST-API-Client-Library. I had a similar problem after upgrading to v3. 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 . '&';
Upvotes: 1