[英]Python Wordpress_XMLRPC NewComment Auth
Not fully understanding the Wordpress API for comments. 没有完全了解Wordpress API的注释。 I'm using the Wordpress_XMLRPC lib and so far I've tried variations of:
我正在使用Wordpress_XMLRPC lib,到目前为止,我已经尝试了以下方法的变体:
wp = Client(WPapilink, Wpusername, WPpassword)
comment = WordPressComment()
comment.content = CommentString
wp.call(comments.NewComment(PostID, comment))
The same settings are able to create a post but when I try adding comments I'm getting: 相同的设置可以创建帖子,但是当我尝试添加评论时,我得到了:
<class 'wordpress_xmlrpc.exceptions.InvalidCredentialsError'>
I know there is comment.user
but what I can't figure out is if it wants an ID (I've tried 0 and 1), a username (tried the admin one) or will accept a string as the name (which would be the ideal). 我知道有
comment.user
但我不知道是要ID(我尝试过0和1),用户名(尝试过管理员)还是接受字符串作为名称(理想)。
I've tried going through the docs but I'm just not getting it. 我已经尝试过文档,但是我没有。 Next step is just inserting directly to the MySQL table if I can't figure this out.
如果我不知道,下一步就是直接插入到MySQL表中。 Would appreciate a nudge in the right direction.
希望能朝正确的方向轻推。
Update: I was looking at the WordPress API and I can't see a reason for this. 更新:我正在查看WordPress API,但看不到原因。 The author doesn't seem to matter for authentication.
作者似乎对身份验证无关紧要。 The auth it's using to create the post is with an admin login and it creates a post just fine so I'm not sure why it fails to add a comment.
用于创建帖子的auth具有管理员登录名,并且可以很好地创建帖子,因此我不确定为什么它无法添加评论。
Alright. 好的。 Figured it out.
弄清楚了。
Comments were enabled for the site but they default to closed when the API posts them. 已为网站启用评论,但默认在API发布它们时关闭。
post.comment_status = 'open'
Set the comments as open when they were posted and it starts working. 将评论发布后将其设置为开放,然后开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.