gdata自动引诱

2024-05-23 20:30:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我运行了一段时间的python脚本在我的blogspot博客上发布文章。 一切都很顺利,直到我开始得到这个身份验证错误

RequestError: {'status': 401, 'body': 'User does not have permission to create new post', 'reason': 'Unauthorized'}

我真的不明白如何通过阅读gdata文档来修复它。你知道吗

你能告诉我怎么做吗?你知道吗

谢谢

下面是我代码中不再有效的部分:

from gdata import service
import gdata
import atom
blogger_service = service.GDataService('xxxxxx','xxxxxx')
blogger_service.service = 'blogger'
blogger_service.account_type = 'GOOGLE'
blogger_service.server = 'www.blogger.com'
blogger_service.ProgrammaticLogin() 
def CreatePublicPost(blogger_service, blog_id, title, content,tags):
    entry = gdata.GDataEntry()
    entry.title = atom.Title('xhtml', title)
    entry.content = atom.Content(content_type='html', text=content)
    for tag in tags :
        category = atom.Category(term=tag, scheme="http://www.blogger.com/atom/ns#")
        entry.category.append(category)
    return blogger_service.Post(entry, '/feeds/%s/posts/default' % blog_id)

Tags: importcomidtitlewwwtypeserviceblog