WC:3.3.3 / WP 4.9 / PHP 5.4.16 / Apache 2.4.4

require_once(__DIR__.'/WooCommerce/Client.php');
require_once(__DIR__.'/WooCommerce/HttpClient/BasicAuth.php');
require_once(__DIR__.'/WooCommerce/HttpClient/HttpClient.php');
require_once(__DIR__.'/WooCommerce/HttpClient/HttpClientException.php');
require_once(__DIR__.'/WooCommerce/HttpClient/OAuth.php');
require_once(__DIR__.'/WooCommerce/HttpClient/Options.php');
require_once(__DIR__.'/WooCommerce/HttpClient/Request.php');
require_once(__DIR__.'/WooCommerce/HttpClient/Response.php');
use Automattic\WooCommerce\Client;

// WC
$woocommerce = new Client(
    'http://localhost/zivoke/wordpress/', 
    'ck_6843d712abffc03c2097980546dc03c3fe23bb67', 
    'cs_288a0fbcd17f392391cd20af98c1514fa92dd31f',
    [
        'wp_api' => true,
        'verify_ssl'=>false,
        'query_string_auth' => true,
        'version' => 'v2',
    ]
);
var_dump($woocommerce);
print_r($woocommerce->get('products'));

结果:

object(Automattic \ WooCommerce \ Client)[1] public'http'=> object(Automattic \ WooCommerce \ HttpClient \ HttpClient)[2] protected'ch'=> null protected'url'=> string'http:// localhost / zivoke / wordpress / wp-json / v2 /'(长度= 45)受保护'consumerKey'=>字符串'ck_6843d712abffc03c2097980546dc03c3fe23bb67'(长度= 43)受保护'consumerSecret'=>字符串'cs_288a0fbcd17f392391cd20af98c1514fa92dd31f'(长度= 43)受保护的' options'=> object(Automattic \ WooCommerce \ HttpClient \ Options)[3] private'options'=> array(size = 4)... private'request'=> null private'response'=> null private'responseHeaders' => null

Fatal error: Uncaught exception 'Automattic\WooCommerce\HttpClient\HttpClientException' with message 'Error: No route was found matching the URL and request method [rest_no_route]

我试过http://localhost/zivoke/wordpress/wp-json/wp/v2/posts

这似乎完美 - 因此wp rest api正在工作 .

不,我做错了什么?它需要php5.6才能运行???

任何帮助表示赞赏 .