Gmail API 线程列表片段
我一直在尝试使用GMail的API和客户端库。我可以用JavaScript的node SDK获取到邮件线程的列表,但返回的内容是空的。
client.gmail.users.threads.list({userId: "me"}).withAuthClient(auth_with_access_token).execute(function (err, response) {
res.json({complete: response.threads})
});
然后我下载了Python的SDK,也用Gmail API的示例获取了线程列表,发现那些返回的内容也是空的。
for thread in threads['threads']:
print 'Thread: %s' % (thread)
线程ID: {u'snippet': u'', u'id': u'146fccb21d960498', u'historyId': u'7177452'}
当我通过获取线程的方法请求线程时,确实能得到一些内容,不过在线程列表中却是空的。
我需要在请求中添加什么额外的信息才能获取到这些内容吗?
谢谢!
1 个回答
3
我可以通过使用这段代码来获取消息的简短内容,前提是先进行身份验证:
message = service.users().messages().get(userId=user_id, id=msg_id, format='raw').execute()
print 'Message snippet: %s' % message['snippet']
这段代码显然是用来提取特定消息的简短内容,但这个原理是一样的。
你可以试试看,这应该能成功。如果不行,可以在这个回答下留言,我会尽量帮你解决。