Ebay API用于列出一个卖家的物品 - GetSellerList

时间:2013-12-17 12:20:26

标签: api ebay ebay-api

有Ebay API经验的人吗?我基本上试图在他们的网站上列出一家商店的所有商品,因此它不会成为公共服务用途。 GetSellerList方法似乎是要走的路,但Ebay网站本身的文档很少,而且根本没有做得很好。

http://developer.ebay.com/DevZone/XML/docs/reference/ebay/GetSellerList.html

我正在尝试代码示例,而我现在遇到的问题是我是否需要UserToken。 #PITA

谢谢,

2 个答案:

答案 0 :(得分:6)

以下是我用过的最低要求:

<?xml version="1.0" encoding="utf-8"?>
<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <RequesterCredentials>
    <eBayAuthToken>--Enter your AuthToken here--</eBayAuthToken>
  </RequesterCredentials>
  <ErrorLanguage>en_US</ErrorLanguage>
  <WarningLevel>High</WarningLevel>
  <StartTimeFrom>2013-06-01T21:59:59.005Z</StartTimeFrom> 
  <StartTimeTo>2013-09-26T21:59:59.005Z</StartTimeTo>
  <EndTimeFrom>2013-09-26</EndTimeFrom>
  <EndTimeTo>2013-11-26</EndTimeTo>
  <GranularityLevel>Coarse</GranularityLevel>
  <UserID>--Enter your seller's name here--</UserID>
  <Pagination>
    <EntriesPerPage>200</EntriesPerPage>
    <PageNumber>1</PageNumber>
  </Pagination>
  <OutputSelector>ItemArray.Item.ItemID</OutputSelector>
  <OutputSelector>ItemArray.Item.Quantity</OutputSelector>
  <OutputSelector>ItemArray.Item.Title</OutputSelector>
  <OutputSelector>ItemArray.Item.PrimaryCategory.CategoryID</OutputSelector>
  <OutputSelector>ItemArray.Item.PrimaryCategory.CategoryName</OutputSelector>
</GetSellerListRequest>

我还必须将这些标题添加到请求中:

X-EBAY-API-APP-NAME             -- Add yours here --
X-EBAY-API-CALL-NAME            GetSellerList
X-EBAY-API-REQUEST-ENCODING     XML
X-EBAY-API-SITEID               0
X-EBAY-API-DEV-NAME             -- Add yours here --
X-EBAY-API-CERT-NAME            -- Add yours here --
X-EBAY-API-COMPATIBILITY-LEVEL  825

我不确定哪些“ - 在这里加你的 - ”条目是公开的,哪些是私密的,所以我谨慎谨慎,我会让你自己拿到它们。 : - )

如果未输入eBayAuthToken,则会收到以下错误:

   <Errors>
      <ShortMessage>Auth token is invalid.</ShortMessage>
      <LongMessage>Validation of the authentication token in API request failed.</LongMessage>
      <ErrorCode>931</ErrorCode>
      <SeverityCode>Error</SeverityCode>
      <ErrorClassification>RequestError</ErrorClassification>
   </Errors>

我希望这会有所帮助。

答案 1 :(得分:1)

<?xml version="1.0" encoding="utf-8"?>
<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <RequesterCredentials>
    <eBayAuthToken>$authToken</eBayAuthToken>
  </RequesterCredentials>
  <ErrorLanguage>en_US</ErrorLanguage>
  <WarningLevel>High</WarningLevel>
  <StartTimeFrom>2015-01-01T00:00:00.005Z</StartTimeFrom> 
  <StartTimeTo>2015-03-31T23:59:59.005Z</StartTimeTo>
  <EndTimeFrom>2015-03-31T23:59:59.005Z</EndTimeFrom>
  <EndTimeTo>2015-05-31T23:59:59.005Z</EndTimeTo>
  <GranularityLevel>Coarse</GranularityLevel>
  <UserID>----testuser----</UserID>
  <Pagination>
    <EntriesPerPage>200</EntriesPerPage>
    <PageNumber>1</PageNumber>
  </Pagination>
  <OutputSelector>ItemArray.Item.ItemID</OutputSelector>
  <OutputSelector>ItemArray.Item.Quantity</OutputSelector>
  <OutputSelector>ItemArray.Item.Title</OutputSelector>
  <OutputSelector>ItemArray.Item.PrimaryCategory.CategoryID</OutputSelector>
  <OutputSelector>ItemArray.Item.PrimaryCategory.CategoryName</OutputSelector>
</GetSellerListRequest>

标头请求值

$headers = array(
        'X-EBAY-API-SITEID:'.SITEID,
        'X-EBAY-API-CALL-NAME:GetSellerList',
        'X-EBAY-API-REQUEST-ENCODING:'.RESPONSE_ENCODING,
        'X-EBAY-API-COMPATIBILITY-LEVEL:' . API_COMPATIBILITY_LEVEL,
        'X-EBAY-API-DEV-NAME:' . API_DEV_NAME,
        'X-EBAY-API-APP-NAME:' . API_APP_NAME,
        'X-EBAY-API-CERT-NAME:' . API_CERT_NAME,
        'Content-Type: text/xml;charset=utf-8'
    );