Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active March 28, 2017 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/73e47b7b2c8fd7b1e6eac1cc891f8441 to your computer and use it in GitHub Desktop.
Save kurozumi/73e47b7b2c8fd7b1e6eac1cc891f8441 to your computer and use it in GitHub Desktop.
【Python】eBayのTrading APIを使ってeBayのユーザーからの問い合わせを取得する方法
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