我正在尝试使用以下代码从 php 获取所有订阅:
<?php
require __DIR__ . '/vendor/autoload.php';
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'https://www.magazzinoperfetto.it', // Your store URL
'ck_c92b6b6452XXXXXXXXXXXXXXXXXX',
'cs_e3380e1c07XXXXXXXXXXXXXXXXXX',
[
'wp_api' => true, // Enable the WP REST API integration
'version' => 'wc/v2' // WooCommerce WP REST API version
]
);
print_r($woocommerce->get('subscriptions'));
?>
如果我将 api 与 woocommerce 产品等一起使用......它是功能性的。但是通过订阅我收到此错误:
致命错误:/var/www/vhosts/magazzinoperfetto.it/httpdocs 中的未捕获异常“Automattic\WooCommerce\HttpClient\HttpClientException”和消息“错误:Nessun percorso fornisce una corrispondenza tra l'URL e le modalità di richiesta [rest_no_route]” /vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:324 堆栈跟踪:#0 /var/www/vhosts/magazzinoperfetto.it/httpdocs/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient。 php(349): Automattic\WooCommerce\HttpClient\HttpClient->lookForErrors(Array) #1 /var/www/vhosts/magazzinoperfetto.it/httpdocs/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(385 ): Automattic\WooCommerce\HttpClient\HttpClient->processResponse() #2 /var/www/vhosts/magazzinoperfetto.it/httpdocs/vendor/automattic/woocommerce/src/WooCommerce/Client。php(82): Automattic\WooCommerce\HttpClient\HttpClient->request('subscriptions', 'GET', Array, Array) #3 /var/www/vhosts/magazzinoperfetto.it/httpdocs/change-sottoscrizione.php(22 ): Automattic\WooCommerce\ 在 /var/www/vhosts/magazzinoperfetto.it/httpdocs/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php 在第 324 行