2015-04-16 95 views
-1

我嘗試使用谷歌的API-S下載電子郵件附件,但在這個過程中,我碰到了一些有趣的錯誤:谷歌的Gmail API的Python下載附件

使用谷歌的例子(from here)爲users.messages.attachments: get method,我我有一個KeyError說沒有這樣的關鍵字data

使用Download Attachments from gmail using Gmail API提出的方法,TypeError: 'Resource' object is not callable提高在該行:

att=gmail_service.users().messages().attachments().get(userId=user_id, messageId=msg_id,id=att_id).execute()

我的代碼的相關部分是:

import codecs 

message = gmail_service.users().threads().get(id=thread['id'],userId='me',format='metadata').execute()['messages'] 
themessage = gmail_service.users().messages().get(userId='me', id=message[0]['id']).execute() 
attachmentid = themessage['payload']['parts'][1]['body']['attachmentId'].encode('utf-8') 
attachment = gmail_service().users().messages().attachments().get(userId='me',messageId=message[0]['id'], id=attachmentid).execute() 

非常感謝您提前對於違反任何一種慣例抱歉。我是一名業餘愛好程序員,我的專業甚至與CS沒有關係。

和電子郵件的原始信息:

{u'historyId': u'87616', u'id': u'14cc2903d8201ce5', u'snippet': u'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dapibus leo auctor vulputate', u'sizeEstimate': 12503, u'threadId': u'14cc2903d8201ce5', u'labelIds': [u'INBOX', u'IMPORTANT', u'CATEGORY_PERSONAL', u'UNREAD'], u'payload': {u'mimeType': u'multipart/mixed', u'headers': [{u'name': u'Delivered-To', u'value': u'[email protected]'}, {u'name': u'Received', u'value': u'by 10.27.172.12 with SMTP id v12csp3301331wle;  Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'X-Received', u'value': u'by 10.194.47.165 with SMTP id e5mr59439281wjn.128.1429193375163;  Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'Return-Path', u'value': u'<[email protected]>'}, {u'name': u'Received', u'value': u'from DUB004-OMC2S3.hotmail.com (dub004-omc2s3.hotmail.com. [157.55.1.142])  by mx.google.com with ESMTPS id k8si15998291wia.75.2015.04.16.07.09.35  for <[email protected]>  (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);  Thu, 16 Apr 2015 07:09:35 -0700 (PDT)'}, {u'name': u'Received-SPF', u'value': u'pass (google.com: domain of [email protected] designates 157.55.1.142 as permitted sender) client-ip=157.55.1.142;'}, {u'name': u'Authentication-Results', u'value': u'mx.google.com;  spf=pass (google.com: domain of [email protected] designates 157.55.1.142 as permitted sender) [email protected]'}, {u'name': u'Received', u'value': u'from DUB122-W21 ([157.55.1.137]) by DUB004-OMC2S3.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751);\t Thu, 16 Apr 2015 07:09:34 -0700'}, {u'name': u'X-TMN', u'value': u'[u8z/PkebpkoUTRJcKA0Traso7CgFYEaU5ZPsEYJzyy0=]'}, {u'name': u'X-Originating-Email', u'value': u'[[email protected]]'}, {u'name': u'Message-ID', u'value': u'<[email protected]>'}, {u'name': u'Return-Path', u'value': u'[email protected]'}, {u'name': u'Content-Type', u'value': u'multipart/mixed; boundary="_7a3a4cda-38d8-405f-985d-255abada5722_"'}, {u'name': u'From', u'value': u'Tung Nguyen Huy <[email protected]>'}, {u'name': u'To', u'value': u'"[email protected]" <[email protected]>'}, {u'name': u'Subject', u'value': u'Chicago'}, {u'name': u'Date', u'value': u'Thu, 16 Apr 2015 16:09:34 +0200'}, {u'name': u'Importance', u'value': u'Normal'}, {u'name': u'MIME-Version', u'value': u'1.0'}, {u'name': u'X-OriginalArrivalTime', u'value': u'16 Apr 2015 14:09:34.0855 (UTC) FILETIME=[F77AD970:01D0784E]'}], 
u'parts': [{u'mimeType': u'multipart/alternative', u'headers': [{u'name': u'Content-Type', u'value': u'multipart/alternative; boundary="_2c3faa5d-3517-45ad-9ae0-82a26eb7b6e5_"'}], u'parts': [{u'mimeType': u'text/plain', u'headers': [{u'name': u'Content-Type', u'value': u'text/plain; charset="iso-8859-1"'}, {u'name': u'Content-Transfer-Encoding', u'value': u'quoted-printable'}], u'body': {u'data': u'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IG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iBEb25lYyBpZCBtb2xsaXMgc2VtLiBNYWVjZW5hcyBmZXVnaWF0IHJpc3VzIHZlbCBmZXVnaWF0IGVmZmljaXR1ci4gRnVzY2UgYW50ZSB0ZWxsdXMsIGJpYmVuZHVtIGF0IHByZXRpdW0gYXVjdG9yLCBtYXR0aXMgZWdldCBpcHN1bS4gTnVuYyBzYWdpdHRpcyB0b3J0b3IgcXVpcyBhcmN1IHZpdmVycmEsIHZlbCBsb2JvcnRpcyBsYWN1cyBldWlzbW9kLiBRdWlzcXVlIGRpY3R1bSB0ZW1wb3IgYmliZW5kdW0uIFNlZCBtYXhpbXVzIGxpYmVybyBzaXQgYW1ldCBqdXN0byBmcmluZ2lsbGEgdHJpc3RpcXVlLiAJCSAJICAgCQkgIA==', u'size': 3451}, u'partId': u'0.0', u'filename': u''}, {u'mimeType': u'text/html', u'headers': [{u'name': u'Content-Type', u'value': u'text/html; charset="iso-8859-1"'}, {u'name': u'Content-Transfer-Encoding', u'value': u'quoted-printable'}], u'body': {u'data': u'PGh0bWw-DQo8aGVhZD4NCjxzdHlsZT48IS0tDQouaG1tZXNzYWdlIFANCnsNCm1hcmdpbjowcHg7DQpwYWRkaW5nOjBweA0KfQ0KYm9keS5obW1lc3NhZ2UNCnsNCmZvbnQtc2l6ZTogMTJwdDsNCmZvbnQtZmFtaWx5OkNhbGlicmkNCn0NCi0tPjwvc3R5bGU-PC9oZWFkPg0KPGJvZHkgY2xhc3M9J2htbWVzc2FnZSc-PGRpdiBkaXI9J2x0cic-PHAgc3R5bGU9ImNvbG9yOiByZ2IoMzQsIDM0LCAzNCk7IGZvbnQtZmFtaWx5OiBhcmlhbCwgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxMi44MDAwMDAxOTA3MzQ5cHg7IHRleHQtYWxpZ246IGp1c3RpZnk7IG1hcmdpbi1ib3R0b206IDE0cHg7IGJhY2tncm91bmQtY29sb3I6IHJnYigyNTUsIDI1NSwgMjU1KTsiPjxmb250IGNvbG9yPSIjM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uPjwvcD4gCQkgCSAgIAkJICA8L2Rpdj48L2JvZHk-DQo8L2h0bWw-', u'size': 5160}, u'partId': u'0.1', u'filename': u''}], u'body': {u'size': 0}, u'filename': u''}, 
{u'mimeType': u'text/plain', u'headers': [{u'name': u'Content-Type', u'value': u'text/plain'}, {u'name': u'Content-Transfer-Encoding', u'value': u'base64'}, {u'name': u'Content-Disposition', u'value': u'attachment; filename="villamosE.txt"'}], u'body': {u'attachmentId': u'ANGjdJ8D_1cYbyaSlXR4LOH0WEcY5G0wXTmiG4d85fkEfkiVGtaicJ_sEsJBSj8UsRfQv79C2Now8DKKvpuN4uhA1x3WBGATfxtFHd6m8YUOQkWPUZje37eLFeLAHjF1eiGo3dg3PPNRidhowbB6dXw4WW2Nqd9DioX3K_M9JmxTq4q_X_GUUHB3R5X_Y9yE-tvFdzeKMdWHLQG5-ah5sVaRDjS4gaD6U2ibMHV75yLfNj3P17xPfG9zU4igMYSS6QPI60Ry5aM7M1S_C30amy-HfJpA6fi-gEqqBtpGHg', u'size': 748}, u'partId': u'1', u'filename': u'villamosE.txt'}], 
u'body': {u'size': 0}, u'filename': u''}} 

回答

0

的不可調用的錯誤似乎暗示你的代碼的最後一行應爲gmail_service.users(),不gmail_service().users()因爲它目前並