【问题标题】:Woocommerce REST API https - Cannot ConnectWoocommerce REST API https - 无法连接
【发布时间】:2017-04-23 13:02:16
【问题描述】:

连接到 WooCommerce API,HTTP 没有问题。

当我将永久链接从 http 更改为 https 时,然后尝试使用我得到的 https url 进行连接:

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

我有一个 SSL 证书,所以我不确定为什么它不起作用?

请帮忙,

非常感谢!

编辑: 请求:HTTP

HTTPS

【问题讨论】:

  • 你能分享你正在做的请愿书吗?另外,您似乎没有进行身份验证
  • @Skatox 谢谢。见附件。
  • 非常感谢。现在我的网站是 https 并且我的 api 已经像魅力一样工作了!
  • 你可以选择我的答案作为答案,这样对我有帮助

标签: wordpress rest ssl woocommerce woocommerce-rest-api


【解决方案1】:

根据WooCommerce REST API documentation

有时某些服务器可能无法解析授权标头 正确(如果您看到“Consumer key is missing”错误) 通过 SSL 进行身份验证时,您遇到了服务器问题)。在这种情况下,您 可以提供消费者密钥/秘密作为查询字符串参数 而是。

检查订单参数是否与示例的顺序相同,没有空格。或者我会使用基本的 HTTPS 身份验证,这就是我使用 https 进行通信的方式:

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

【讨论】:

  • 谢谢,看来这是 SSL 的问题: RESPONSE: stdClass Object ( [body] => {"errors":[{"code":"woocommerce_api_authentication_error","message":"消费者密钥无效。"}]} [code] => 401 [headers] => Array ([Date] => Mon, 24 Apr 2017 22:38:41 GMT [Server] => Apache/2.4.10 [Transfer -Encoding] => 分块 [Content-Type] => application/json; charset=UTF-8 ) )
  • 重新生成消费者密钥并尝试使用这两种方法进行身份验证。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-04
  • 1970-01-01
  • 2022-07-19
  • 2020-09-02
  • 1970-01-01
  • 2017-09-22
相关资源
最近更新 更多