API-vendor/docs/实际经验/如何访问woocommerceAPI.md

39 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 如何访问woocommerceAPI
## API服务器配置
`src\config\config.local.ts`
```ts
const config = {
wpSite: [
//
{
id: '111', // 起一个比较大的
wpApiUrl: 'http://wp-test.local', // wordpress地址
consumerKey: 'ck_d6fc55914e2aba162bcf979a549e965a751e71ee', // woocommerce advanced 中创建rest api的key
consumerSecret: 'cs_5828d66ddd23f17f7c7693f4414756ddb637fb47',// woocommerce advanced 中创建rest api的key
name: 'Local',
// email配置对访问不重要
email: '*',
emailPswd: '*',
},
//...
]
}
```
## 开通woocommere 权限(key
key只要添加即可使用(一般测试直接添加具有 READ WRITE 权限即可)
![1760323937560](image/如何连接wordpress/1760323937560.png)
## 常见问题
### SSL证书问题
因为是我们访问 woocommerce 所以可以直接忽略 ssl 错误(比如 axios 直接忽略)
如果遇到SSL证书错误(如`DEPTH_ZERO_SELF_SIGNED_CERT`),请参考:[SSL证书问题解决方案](./SSL证书问题解决方案.md)