RESTful API - WooCommerce REST API请求因curl而失败

时间:2014-02-20 13:24:48

标签: api rest woocommerce restful-authentication

我最近更新到WooCommerce 2.1的最新版本,其中包含new RESTful API。 我对cURL或RESTful API没有多少经验,但我认为我给它一个游戏。

我的网站是sergedenimes.com,我在服务器上设置了SSL。

如果我运行curl https://sergedenimes.com/wc-api/v1,我会得到一个很长的json输出:

{
   "store":{
      "name":"Serge DeNimes",
      "description":"Original, Urban T-Shirts Of The Highest Quality by Oliver Proudlock",
      "URL":"http:\/\/sergedenimes.com",
      "wc_version":"2.1.2",
      "routes":{
         "\/":{
            "supports":[
               "HEAD",
               "GET"
            ],
            "meta":{
               "self":"http:\/\/sergedenimes.com\/wc-api\/v1\/"
            }
         },
         "\/customers":{ etc.....

这表明api本身正在发挥作用。但是,当我传递使用身份验证的请求时:

curl https://sergedenimes.com/wc-api/v1/orders -u my_key:my_secret

我得到了回应:

{
   "errors":[
      {
         "code":"woocommerce_api_authentication_error",
         "message":"Consumer Key is missing"
      }
   ]
}

我的语法是否正确?我在WP管理员下设置了我的密钥和秘密并传递了值,但似乎我认为我没有按照我的要求传递它。

有什么想法吗?

1 个答案:

答案 0 :(得分:6)

确保您在WooCommerce下启用了安全结帐选项 - >设置 - >查看。如果您启用了该选项,它将仅使用基本身份验证。

相关问题