1
votes

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

2 Answers

0
votes

Solved.

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

0
votes

For me it was my staging server being basic auth protected.