doubi7346 2015-12-23 09:57
浏览 105
已采纳

WooCommerce REST API无效的JSON

I have seen some posts identical but I couldn't yet solve me issue.

try
{
     $client        = new WC_API_Client($woocommerce['url'], 
                                        $woocommerce['consumer_key'], 
                                        $woocommerce['consumer_secret'],
                                        array('ssl_verify'      => FALSE,
                                              'validate_url'    => FALSE,
                                              'debug'           => TRUE));

     $listOfOrders  = $client->orders->get(null, array('status' => 'completed'));
}
catch (WC_API_Client_Exception $e) 
{
    echo $e->getMessage() . PHP_EOL;
    echo $e->getCode() . PHP_EOL;

    if ( $e instanceof WC_API_Client_HTTP_Exception ) 
    {
        print_r( $e->get_request() );
        print_r( $e->get_response() );
    }
}

I'm working in a localhost environment and I dunno if that's the problem. I have download the most recent WooCommerce and Wordpress versions.

Invalid JSON returned for http://localhost/wordpress/shop/wc-api/v2/orders?status=completed&oauth_consumer_key=ck_0314d4b93271c05ebcbdab1735f0404bd633c59c&oauth_timestamp=1450863807&oauth_nonce=a202d26bd1cbbde97926b16af2692af90a2b4422&oauth_signature_method=HMAC-SHA256&oauth_signature=pGG%2BP7FYIYP%2F87TFtTAZQnL39vEfPCP%2Fjiu9VqiJvaA%3D. 400

I thought the problem might be due to the use of localhost and I changed to my local IP address and did not work either. I have checked if cURL and JSON are enabled on phpinfo() and they are.

After copy and paste the link into the browser I get the message

-1

EDIT 1: I went to my hosting, and created a subdomain like http://woocommerce.mydomain.com and the problem persists.

  • 写回答

2条回答 默认 最新

  • dsbx40787736 2015-12-30 12:03
    关注

    Solved.

    The problem was the domain. I was using http://localhost/myproject/store/ when should be http://localhost/myproject/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作