2017-04-23 122 views
1

連接到WooCommerce API,HTTP沒有問題。Woocommerce REST API https - 無法連接

當我改變從HTTP到HTTPS的永久鏈接,然後嘗試使用HTTPS URL我得到連接:

{ 
    "code": "woocommerce_rest_cannot_view", 
    "message": "Sorry, you cannot list resources.", 
    "data": { 
    "status": 401 
    } 
} 

我有一個SSL證書,所以我不知道爲什麼它不會工作?

請幫忙,

非常感謝!

編輯: 請求:HTTP enter image description here enter image description here

enter image description here

HTTPS

https postman req

https postman fail woocommerce https

+0

您可以分享您正在製作的請願書嗎?另外,它似乎是你不認證 – Skatox

+0

@Skatox謝謝。 見附件。 –

回答

0

根據WooCommerce REST API documentation

偶爾有些服務器可能無法解析授權頭 正確(如果你看到的時候 認證通過SSL,你有一臺服務器發出「消費關鍵是缺少」錯誤)。在這種情況下, 可能會提供消費者密鑰/祕密作爲查詢字符串參數 。

檢查訂單參數是否與示例相同,無空格。或者我會使用基本的HTTPS身份驗證,這就是我使用https進行交流的方式:

https://localhost/wp-json/wc/v1/orders?consumer_key=ck_xxxxxxxxxxxxxx&consumer_secret=xxxxxxxxxxxxxxx 
+0

謝謝,所以它似乎是一個SSL問題: 迴應: stdClass對象([body] => {「錯誤」:[{「code」:「woocommerce_api_authentication_error」,「消息」:「消費者密鑰無效「}}} [code] => 401 [headers] => Array([Date] => Mon,24 Apr 2017 22:38:41 GMT [Server] => Apache/2.4.10 [Transfer-Encoding] = > chunked [Content-Type] => application/json; charset = UTF-8)) –

+0

重新生成使用者密鑰並嘗試使用這兩種方法進行身份驗證。 – Skatox