【发布时间】:2018-06-15 15:40:29
【问题描述】:
我正在尝试使用他们的 API 从 gmail 的电子邮件中提取附件,并且在尝试插入变量时遇到了意外的关键字参数。我非常习惯 Javascript,所以这可能就是我遇到此错误并出错的原因,但这里是相关的代码块:
def main():
credentials = get_credentials()
gsa = gspread.authorize(credentials)
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)
query = ['plc/trending/31day']
for x in query:
results = service.users().messages().list(userId='me', labelIds=None, q='label:' + x, pageToken=None, maxResults=1, includeSpamTrash=None).execute()
mesgid = results['messages'][0]['id']
attresults = service.users().messages().get(userId='me', id=mesgid, format=None, metadataHeaders=None).execute()
attid = attresults['payload']['parts'][1]['body']['attachmentId']
grabattachment = service.users().messages().attachments().get(userId='me', messageId = mesgid, attachmentId = attid)
【问题讨论】:
-
我在official API documentation 中没有看到任何提到该方法的
attachmentId参数,没有。
标签: python python-3.x gmail-api