Php WooCommerce Rest API给出语法错误
我正在做一个辅助项目,我一直在尝试与WooCommerce REST API进行交互 我的一切似乎都是正确的。我创建了正确的关键点,因为它们与cURL一起工作。但是当我尝试使用Automattic提供的php包装器时,一切都停止了 我完全按照他们的指示设置了代码: 需要目录“//供应商/autoload.php' 使用Automatic\WooCommerce\ClientPhp WooCommerce Rest API给出语法错误,php,wordpress,rest,curl,woocommerce-rest-api,Php,Wordpress,Rest,Curl,Woocommerce Rest Api,我正在做一个辅助项目,我一直在尝试与WooCommerce REST API进行交互 我的一切似乎都是正确的。我创建了正确的关键点,因为它们与cURL一起工作。但是当我尝试使用Automattic提供的php包装器时,一切都停止了 我完全按照他们的指示设置了代码: 需要目录“//供应商/autoload.php' 使用Automatic\WooCommerce\Client $woocommerce = new Client( 'https://mywebsitenamegoeshere
$woocommerce = new Client(
'https://mywebsitenamegoeshere.com',
'##########',
'##########',
[
'wp_api' => true,
'version' => 'wc/v2',
'query_string_auth' => true
]
);
我只是想请求列出端点(这也适用于cURL),但一旦我尝试通过php包装器进行交互,就会收到以下错误消息:
Fatal error: Uncaught exception 'Automattic\WooCommerce\HttpClient\HttpClientException' with message 'Syntax error' in /nas/content/live/wwitssltest/wp-content/themes/twentyseventeen/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:346
Stack trace: #0 /nas/content/live/wwitssltest/wp-content/themes/twentyseventeen/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(385): Automattic\WooCommerce\HttpClient\HttpClient->processResponse()
#1 /nas/content/live/wwitssltest/wp-content/themes/twentyseventeen/vendor/automattic/woocommerce/src/WooCommerce/Client.php(82): Automattic\WooCommerce\HttpClient\HttpClient->request('', 'GET', Array, Array)
#2 /nas/content/live/wwitssltest/wp-content/themes/twentyseventeen/ticket-data-test-template.php(15): Automattic\WooCommerce\Client->get('')
#3 /nas/content/live/wwitssltest/wp-includes/template-loader.php(74): include('/nas/content/li...')
#4 /nas/content/live/wwitssltest/wp-blog-header.php(19): require_once('/nas/content/li...')
#5 /nas/content in /nas/content/live/wwitssltest/wp-content/themes/twentyseventeen/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 346
当我查看文件时,特别是HttpClient.php
我能看到的最具体的信息是JSON可能没有正确格式化
这件衣服看起来很干净利落,但我所做的一切都没有什么不同
除了返回客户端对象的
之外。您解决了吗?我没有解决问题。然后我转到另一个项目。