在我的 WordPress 端,我安装了 REST-API 插件并通过以下方式成功获取帖子:
\n\nmywp.org/wp-json/wp/v2/posts\nRun Code Online (Sandbox Code Playgroud)\n\n但是,只允许“get”,如果我执行“post”等任何其他操作,它会返回 401。我正在使用 Chrome 应用程序“Postman”和基本身份验证。
\n\n我得到什么:
\n\n "code": "rest_cannot_create",\n "message": "Sorry, you are not allowed to create new posts.",\n "data": {\n "status": 401\nRun Code Online (Sandbox Code Playgroud)\n\n这是标题:
\n\nAccess-Control-Allow-Credentials \xe2\x86\x92true\nAccess-Control-Allow-Headers \xe2\x86\x92Authorization\nAccess-Control-Allow-Methods \xe2\x86\x92POST, GET, OPTIONS, PUT, DELETE\nAccess-Control-Allow-Origin \xe2\x86\x92\nAccess-Control-Expose-Headers \xe2\x86\x92X-WP-Total, X-WP-TotalPages\nAllow \xe2\x86\x92GET\nConnection \xe2\x86\x92Keep-Alive\nContent-Length \xe2\x86\x92111\nContent-Type \xe2\x86\x92application/json; charset=UTF-8\nRun Code Online (Sandbox Code Playgroud)\n\n我发现这里提出了同样的问题,但答案对我不起作用。
\n\n我是rest-api 的新手,不知道我应该做什么。
\n\n谢谢你!
\n