请不要将其标记为重复 . 这些帖子上的解决方案似乎不起作用 .

我想用curl远程发布我的wordpress博客 .

我正在使用此curl命令发布到wordpress

curl -D- -X POST -H "Authorization: Basic bTRtdxXM6R3JTcnYyMDA299999" -H "Content-Type: application/json" --data '{"title": "this is my new post sent from curl","content": "This is the content","status": "publish"}' "http://mywebsite.com/wp-json/wp/v2/posts

我得到的回应是

HTTP/1.1 401 Unauthorized
Date: Thu, 13 Apr 2017 19:47:42 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d2221a0a91149358bf8744eb3d5816cea1492112861; expires=Fri, 13-Apr-18 19:47:41 GMT; path=/; domain=.mywebsite.com; HttpOnly
X-Powered-By: PHP/5.6.30
X-Robots-Tag: noindex
Link: <http://mywebsite.com/wp-json/>; rel="https://api.w.org/"
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Access-Control-Allow-Headers: Authorization, Content-Type
Allow: GET
Vary: Accept-Encoding,User-Agent
Server: cloudflare-nginx
CF-RAY: 34f0f046a79f081d-SIN

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

我已经尝试了所有我能做但却无法工作的东西 . 有人建议将以下内容添加到htaccess中,但不起作用

# BEGIN WP BASIC Auth
<IfModule mod_rewrite.c>
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
</IfModule>
# END WP BASIC Auth

我也试过安装https://wordpress.org/plugins/rest-api/插件 .

当前的PHP版本:5.6托管在Godaddy经济托管上 . Wordpress版:WordPress 4.7.3

请帮助,我已经尝试了几天,但没有一个解决方案似乎有效 .