I'm working on WooCommerce API, but I have problem with request.
Sometimes the API request return 404 or redirect to "my-account".
API request example :
https://example.com/index.php/wc-api/v3/products?consumer_key=ck_XXXXXXXXX&consumer_secret=cs_XXXXXXXXX`.
Pretty links are enabled.
Here is my .htacess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any ideas ?
Please download SDK from here: https://packagist.org/packages/automattic/woocommerce and take guidance from here: https://woothemes.github.io/woocommerce-rest-api-docs/. And create api credential form wordpress admin end woocommerce>settings>add new key
$client = 'ck_63aade4xxxxxxxxxxxxxxx'; //put client key
$secret = 'cs_673d7cdxxxxxxxxxxxxxxx'; //put secret key
require __DIR__ . '/restapi/vendor/autoload.php'; //give your sdk autoload.php path
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://localhost:8888/woocommerce/', //site url
$client,
$secret, // Your consumer secret
[
'version' => 'v3' // WooCommerce API version
]
);
print_r($woocommerce->get(''));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With