2016-04-28 29 views
7

Sto lavorando su API WooCommerce, ma ho problemi con la richiesta.Ritorno API WooCommerce 404 non trovato

A volte la richiesta API restituisce 404 o reindirizza a "mio-account". Richiesta

API esempio:

https://example.com/index.php/wc-api/v3/products?consumer_key=ck_XXXXXXXXX&consumer_secret=cs_XXXXXXXXX`. 

link Piuttosto sono abilitati.

Ecco il mio .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 

Tutte le idee?

+0

Hai provato tutte queste cose: http://stackoverflow.com/questions/22429771/woocommerce-rest-api-returns-404- non trovato https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/11 http://stackoverflow.com/questions/22710078/woocommerce-rest-api-404-error http://woopos.com.au/faq/getting-404-error-page-found/ –

+0

Sì, ho provato di tutto. Nulla funziona, ho permalink abilitato – user1269586

+0

C'è uno spazio nell'URI, spero che sia solo un errore in questa domanda, non nel tuo codice: 'consumer_secret = cs_XXXXXXXXX' – tillz

risposta

1

Si prega di scaricare SDK da qui: https://packagist.org/packages/automattic/woocommerce e prendere la guida da qui: https://woothemes.github.io/woocommerce-rest-api-docs/. E creare la forma api credenziali wordpress finali amministratore woocommerce> Impostazioni> Aggiungi nuova chiave

$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(''));