【问题标题】:woocommerce REST API Get customer by emailwoocommerce REST API 通过电子邮件获取客户
【发布时间】:2017-12-02 21:03:33
【问题描述】:

通过电子邮件获取客户

https://localhost/biobays/wp-json/wc/v2/customers/2 通过 id 获取客户正在工作。但 https://localhost/biobays/wp-json/wc/v2/customers/email/test@t.comhttps://localhost/biobays/wp-json/wc/v2/customers?email=test@t.com 不工作

我希望确实会检索到用户信息。

我的回复是空的。

PS:这在旧 v3 https://localhost/biobays/wc-api/v3/customers/email/test@t.com 上工作得很好

【问题讨论】:

    标签: woocommerce-rest-api


    【解决方案1】:

    乔, 我做了一个小测试,这是您需要对 API 进行的调用:

    $params = array("email" => "test@t.com");
    $getContact = $wcApi->get('customers',$params);
    
    echo "<pre>";
    print("<pre>".print_r($getContact , true)."</pre>");
    echo"</pre>";
    

    如果您要测试 url,请像这样调用:

    https://localhost/biobays/wp-json/wc/v2/customers?email=test%40t.com&consumer_key=YOUR_CONSUMER_KEY&consumer_secret=YOUR_CONSUMER_SECRET
    

    如果不存在电子邮件,则返回一个空数组。

    【讨论】:

    • 你好瑞克,我会测试你的解决方案。如果我理解得很好,我的问题与编码 %40 而不是@有关。我会检查并给你反馈。非常感谢!
    • 嗨 Rick,localhost/biobays/wp-json/wc/v2/… 在 curl 上运行得很好,但在 Alamofire 上,这没有任何回报。很奇怪……
    • 我不敢相信我终于找到了我要找的东西!感谢你的回答。我希望我能投不止一个赞成票!
    • 这似乎不适用于 REST v3?我也需要通过电子邮件/邮编获取订单
    【解决方案2】:

    对于在 5.8.x 上测试的新版本 api,这似乎工作正常

    https://yourdomain.com/wp-json/wc/v3/customers?email=xxxxxxx@gmail.com

    【讨论】:

      猜你喜欢
      • 2015-03-01
      • 2018-11-02
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多