在Wordpress.com上发布REST API [错误401,不允许]
问题描述:
我想在我的一个wordpress.com网站(免费的wordpress.com平台上托管的wordpress网站)上发布文章。在Wordpress.com上发布REST API [错误401,不允许]
端点,言归正传:https://public-api.wordpress.com/wp/v2/sites/donnadulcinea.wordpress.com/posts
随着基本认证头。请求(测试)的车身,
{"title":"New Rest Post"}
响应:
{
"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create posts as this user.",
"data": {
"status": 401
}
}
有什么不对?我在哪里可以找到最后一个在wordpress.com域上发布的简单发布示例?
答
首先,你使用的是基本的auth插件吗? here
其次,我不确定您的端点是否正确。这是我如何使用:
http://localhost/wp-json/wp/v2/posts
我想在我的网站,这个JSON:
{
"title":"title",
"content":"content",
"categories":"news",
"status":"publish"
}
和它的工作