我正在使用ebay api构建一个应用程序,当我尝试在我的帐户上添加新的列表时,我从ebay服务器得到了非常奇怪的回复,如下所示:
# -*- coding: utf-8 -*-
'''
© 2012-2013 eBay Software Foundation
Authored by: Tim Keefer
Licensed under CDDL 1.0
'''
import os
import sys
import datetime
from optparse import OptionParser
sys.path.insert(0, '%s/../' % os.path.dirname(__file__))
from samples.common import dump
import ebaysdk
from ebaysdk.utils import getNodeText
from ebaysdk.exception import ConnectionError
from ebaysdk.trading import Connection as Trading
def init_options():
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-d", "--debug",
action="store_true", dest="debug", default=False,
help="Enabled debugging [default: %default]")
parser.add_option("-y", "--yaml",
dest="yaml", default='ebay.yaml',
help="Specifies the name of the YAML defaults file. [default: %default]")
parser.add_option("-a", "--appid",
dest="appid", default=None,
help="Specifies the eBay application id to use.")
parser.add_option("-p", "--devid",
dest="devid", default=None,
help="Specifies the eBay developer id to use.")
parser.add_option("-c", "--certid",
dest="certid", default=None,
help="Specifies the eBay cert id to use.")
(opts, args) = parser.parse_args()
return opts, args
def AddItem(opts):
"""http://www.utilities-online.info/xmltojson/#.UXli2it4avc
"""
try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
certid=opts.certid, devid=opts.devid, warnings=False)
myitem = {
"Item": {
"Title": "Testiranje",
"Description": "Opis za testiranje",
"PrimaryCategory": {"CategoryID": "377"},
"StartPrice": "1.0",
"BuyItNowPrice": "1.0",
"CategoryMappingAllowed": "true",
"Country": "US",
"ConditionID": "3000",
"Currency": "USD",
"DispatchTimeMax": "3",
"ListingDuration": "Days_7",
"ListingType": "FixedPriceItem",
"PaymentMethods": "PayPal",
"PayPalEmailAddress": "veryrarethings@gmail.com",
"PictureDetails": {"PictureURL": "http://i.ebayimg.com/00/s/NTAwWDM0NA==/z/7B0AAOSwE9RZyhg6/$_58.JPG"},
"PostalCode": "52804",
"Quantity": "1",
"ReturnPolicy": {
"ReturnsAcceptedOption": "ReturnsAccepted",
"RefundOption": "MoneyBack",
"ReturnsWithinOption": "Days_7",
"Description": "If you are not satisfied, return the book for refund.",
"ShippingCostPaidByOption": "Buyer"
},
"SellerProfiles": {
"SellerPaymentProfile": {
"PaymentProfileName": "PayPal:Immediate pay",
},
"SellerReturnProfile": {
"ReturnProfileName": "7 Day Return Policy",
},
"SellerShippingProfile": {
"ShippingProfileName": "USPS First Class, Priority, Priority Express Flat Rate Envelope",
}
},
"ShippingDetails": {
"ShippingType": "Calculated",
"ShippingServiceOptions": {
"ShippingServicePriority": "1",
"ShippingService": "USPSMedia"
},
"CalculatedShippingRate": {
"OriginatingPostalCode": "52804",
"PackagingHandlingCosts": "0.0",
"ShippingPackage": "PackageThickEnvelope",
"WeightMajor": "1",
"WeightMinor": "0"
}
},
"Site": "US"
}
}
api.execute('AddFixedPriceItem', myitem)
dump(api)
except ConnectionError as e:
print(e)
print(e.response.dict())
if __name__ == "__main__":
(opts, args) = init_options()
print("Trading API Samples for version %s" % ebaysdk.get_version())
AddItem(opts)
现在一切正常,但是当我尝试使用python myscript.py调用它时,我得到以下错误作为ebay服务器的响应:
Trading API Samples for version 2.1.4
u'AddFixedPriceItem: Class: RequestError, Severity: Error, Code: 127, Application name invalid. API application "None" invalid.'
{
"Ack": "Failure",
"Timestamp": "2018-03-02T19:21:02.360Z",
"Errors": {
"SeverityCode": "Error",
"ErrorClassification": "RequestError",
"ErrorCode": "127",
"LongMessage": "API application \"None\" invalid.",
"ErrorParameters": {
"_ParamID": "0",
"Value": "None"
},
"ShortMessage": "Application name invalid."
},
"Version": "1057",
"Build": "E1057_UNI_API5_18681882_R1"
}
我很困惑,为什么要说我的申请名称无效?我需要你的帮助。提前谢谢。