我必须将我的django项目与Ebay集成。我已经关注了SDK存储库,并在开发人员论坛上设置了一个帐户,如此处指定 Ebay SDK Repository for Python
我尝试运行以下函数来添加项目
#!/usr/bin/env python3
从ebaysdk.交易导入连接
if __name__ == '__main__':
api = Connection(config_file="ebay.yaml", domain="api.sandbox.ebay.com", debug=True)
request = {
"Item": {
"Title": "Professional Mechanical Keyboard",
"Country": "US",
"Location": "IT",
"Site": "US",
"ConditionID": "1000",
"PaymentMethods": "PayPal",
"PayPalEmailAddress": "nobody@gmail.com",
"PrimaryCategory": {"CategoryID": "33963"},
"Description": "A really nice mechanical keyboard!",
"ListingDuration": "Days_10",
"StartPrice": "150",
"Currency": "USD",
"ReturnPolicy": {
"ReturnsAcceptedOption": "ReturnsAccepted",
"RefundOption": "MoneyBack",
"ReturnsWithinOption": "Days_30",
"Description": "If you are not satisfied, return the keyboard.",
"ShippingCostPaidByOption": "Buyer"
},
"ShippingDetails": {
"ShippingServiceOptions": {
"FreeShipping": "True",
"ShippingService": "USPSMedia"
}
},
"DispatchTimeMax": "3"
}
}
api.execute("AddItem", request)
但是我遇到了以下错误
ebaysdk.exception.ConnectionError: "AddItem: Class: RequestError, Sernity: Error, Code: 120, 您需要创建一个卖家账户。在您发布此商品之前,我们需要一些其他信息来创建卖家账户。
020-01-16 17:13:02,385 ebaysdk [警告]:添加项:类:请求错误,严重性:警告,代码:21920200,退货策略属性无效 退货政策属性返回说明在此站点上无效
我不知道如何在 Ebay 上设置卖家账户或退货政策。我从我这边做了很多研发,但找不到解决方案。任何这方面的帮助将不胜感激。
您的凭据有问题,请复制沙盒凭据,如果您想生成身份验证令牌,请访问此 URL:https://developer.ebay.com/DevZone/build-test/test-tool/?index=0 并生成令牌,如果您想找到您的沙盒凭据,请访问: https://developer.ebay.com/my/keys 如果您是新用户,请注册 eBay,可能需要一周或 2 天才能接受您的帐户,如需注册,请访问: https://developer.ebay.com/signin
ebay-yaml 文件:
name: ebay_api_config
# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
compatability: 719
appid: ENTER_YOUR_APPID_HERE
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE
# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
compatability: 719
appid: ENTER_YOUR_APPID_HERE
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE
# Finding API - https://www.x.com/developers/ebay/products/finding-api
svcs.ebay.com:
appid: ENTER_YOUR_APPID_HERE
version: 1.0.0
# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
open.api.ebay.com:
appid: ENTER_YOUR_APPID_HERE
version: 671
添加项代码:
#!/usr/bin/env python3
from ebaysdk.trading import Connection
if __name__ == '__main__':
api = Connection(config_file="<your-yaml-file-path>", domain="api.sandbox.ebay.com", debug=True)
request = {
"Item": {
"Title": "Professional Mechanical Keyboard",
"Country": "US",
"Location": "IT",
"Site": "US",
"ConditionID": "1000",
"PaymentMethods": "PayPal",
"PayPalEmailAddress": "nobody@gmail.com",
"PrimaryCategory": {"CategoryID": "33963"},
"Description": "A really nice mechanical keyboard!",
"ListingDuration": "Days_10",
"StartPrice": "150",
"Currency": "USD",
"ReturnPolicy": {
"ReturnsAcceptedOption": "ReturnsAccepted",
"RefundOption": "MoneyBack",
"ReturnsWithinOption": "Days_30",
"Description": "If you are not satisfied, return the keyboard.",
"ShippingCostPaidByOption": "Buyer"
},
"ShippingDetails": {
"ShippingServiceOptions": {
"FreeShipping": "True",
"ShippingService": "USPSMedia"
}
},
"DispatchTimeMax": "3"
}
}
d=api.execute("AddItem", request)
print(d)