Last active
March 28, 2017 08:23
-
-
Save kurozumi/73e47b7b2c8fd7b1e6eac1cc891f8441 to your computer and use it in GitHub Desktop.
【Python】eBayのTrading APIを使ってeBayのユーザーからの問い合わせを取得する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import logging | |
import re | |
from ebaysdk.trading import Connection as Trading | |
from ebaysdk.exception import ConnectionError | |
if __name__ == "__main__": | |
try: | |
params = { | |
'DetailLevel': 'ReturnHeaders', | |
} | |
api = Trading(appid="YOUR_APPID", devid="YOUR_DEVID", certid="YOUR_CERTID", token="YOUR_AUTH_TOKEN") | |
api.execute('GetMyMessages', params) | |
for message in api.response.reply.Messages.Message: | |
# eBayからのメッセージはスルー | |
if message.Sender == 'eBay': | |
continue | |
data = { | |
"sending_user_id": message.SendingUserID, | |
"sender": message.sender, | |
"message_id": message.MessageID, | |
"receive_data": message.ReceiveDate, | |
"subject": message.Subject, | |
} | |
print(data) | |
except ConnectionError as e: | |
d = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S") | |
print("{} {}".format(d, e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment