Saa*_*aad 5 wordpress woocommerce woocommerce-rest-api
您好,我正在使用 WooCommerce API - Node.js 客户端https://www.npmjs.com/package/woocommerce-api
我正在尝试创建一个需要向服务器发出 POST 请求的客户。以下是初始化 woocomerece REST API 的代码:
var WooCommerceAPI = require('woocommerce-api');
var WooCommerce = new WooCommerceAPI({
url: 'http://example.com',
consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
wpAPI: true,
version: 'wc/v1'
});
Run Code Online (Sandbox Code Playgroud)
这是创建客户的代码:
var data = {
email: 'john.doe@example.com',
first_name: 'John',
last_name: 'Doe',
username: 'john.doe',
billing: {
first_name: 'John',
last_name: 'Doe',
company: '',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US',
email: 'john.doe@example.com',
phone: '(555) 555-5555'
},
shipping: {
first_name: 'John',
last_name: 'Doe',
company: '',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US'
}
};
WooCommerce.post('customers', data, function(err, data, res) {
console.log(res);
});
Run Code Online (Sandbox Code Playgroud)
但我不断收到服务器的以下响应。
{
"code":"woocommerce_rest_authentication_error",
"message":"Invalid signature - provided signature does not match.",
"data":{"status":401}
}
Run Code Online (Sandbox Code Playgroud)
然而,任何对服务器上的 GET 请求都有效,例如:我可以获得产品列表。
| 归档时间: |
|
| 查看次数: |
12986 次 |
| 最近记录: |