Blogger API v3.0 中“评论”可用的方法如下
列表
检索帖子的评论列表。
获取
通过其 commentId 检索一个评论资源。
同意
将评论标记为非垃圾邮件。
删除
通过 ID 删除评论。
按博客列出
检索博客的所有帖子的评论,可能已过滤。
标记为垃圾邮件
将评论标记为垃圾邮件。这会将评论的状态设置为垃圾邮件,并在默认评论呈现中将其隐藏。
How can i insert comments for a post through Blogger API v3.0?
最佳答案
我看到同样的问题,所以我创建了一个xml方式来插入评论,看看吧。 NODE JS solution
const { google } = require('googleapis')
const axios = require('axios')
const redirectUri = 'https://developers.google.com/oauthplayground'
async function endRequest(data){
try {
return data.status
} catch (error) {
return error
}
}
async function send(dataAuth){
var oAuth2Client = new google.auth.OAuth2(dataAuth.clientId, dataAuth.clientSecret, redirectUri)
oAuth2Client.setCredentials({refresh_token : dataAuth.refreshToken})
var accessToken = oAuth2Client.getAccessToken()
var endPoint = `https://www.blogger.com/feeds/${dataAuth.bloggerId}/${dataAuth.postId}/comments/default`
var requestBody = "<entry xmlns='http://www.w3.org/2005/Atom'>\n" +
`<content type=\"html\">${dataAuth.replaceString}</content>\n` +
"</entry>"
let axiosConfiguration = {
headers: {
'Content-Type': 'application/atom+xml',
'Authorization': `Bearer ${(await accessToken).token}`
}
}
return axios.post(endPoint, requestBody, axiosConfiguration)
.then((res) => endRequest(res))
.catch((err) => endRequest(err))
}
module.exports = {send}
关于javascript - 通过 Blogger API v3.0 为帖子插入评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59484171/