如何使用(ba)sh cURL通过基本身份验证发布到Wordpress?

问题描述 投票:0回答:1

1。我在想什么

我正在尝试使用(POSTWordpressbash到我的cURL网站,但用户授权似乎不起作用。

到目前为止,我一直在尝试的是

curl \
    -u ${USERNAME}:${PASSWORD} \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"title": "this is a test"}' \
    --url http://mywebsite.com.br/wp-json/wp/v2/posts/

2。我得到的

{
    "code": "rest_cannot_create",
    "message": "Sorry, you are not allowed to create posts as this user.",
    "data": {"status": 401}
}

我在做什么错?也许-u标志不是我要寻找的标志?这就是我通常在使用BasicAuth时尝试的方法;这里不是这样吗? wp-json规格正确吗?

wordpress bash curl quotes
1个回答
0
投票

在问题中,我正在使用Basic Authentication,它实际上是需要启用

您可以通过从Github下载WP Basic Auth插件,然后在您的Wordpress网站中上载,安装和激活它来进行操作。

完成后,问题的代码应该可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.