2017-03-31 59 views
1

使用WC-API(https://github.com/woocommerce/wc-api-phpwoocommerce API V2返回未捕獲的異常

我的客戶端功能:(字面相同的文檔)

$woocommerce = new Client(
    $store_url, // Your store URL 
    $consumer_key, // Your consumer key 
    $consumer_secret, // Your consumer secret 
    [ 
     'wp_api' => true, // Enable the WP REST API integration 
     'version' => 'wc/v2', // WooCommerce WP REST API version 
     'query_string_auth' => true // Force Basic Authentication as query string true and using under HTTPS 
    ] 
); 

,當我嘗試用

$results = $woocommerce->get(''); 

$results = $woocommerce->get('products'); 

或任何其他端點它給了我:

An uncaught Exception was encountered

Type: Automattic\WooCommerce\HttpClient\HttpClientException

Message: Error: No route was found matching the URL and request method [rest_no_route]

如果我改變版本「WC/V1」這是工作確定。

是否需要添加一些其他插件或附加代碼才能使v2工作?

回答

0

嘗試發送您的要求就是這樣,你的creds在參數:

$res = ($woocommerce->get('orders?status=processing&consumer_key=ck_XXXXXXXXXXXXXXXXXXXXXXXXX&consumer_secret=cs_XXXXXXXXXXXXXXXXXXXXXXXXX')); 
+0

返回正確的數據爲V1,但給了我類似的錯誤在V2。無論如何,在問題出現一週後,有一個更新會自動修復它。感謝您的回答。 – Tsefo