给定一个易趣网址,有什么方法可以获得商品详情

时间:2016-03-04 16:48:48

标签: ebay ebay-api

说我有一个网址,例如http://www.ebay.com/itm/Harry%20Potter%20and%20the%20Deathly%20Hallows%207%20by%20J.%20K.%20Rowling%20(2007,%201st%20Edition)/322028146082

我想了解这个项目的详细信息,但API接缝要求我知道像我们没有的productId这样的信息。我该怎么做呢?

在问这个问题时,我找到了答案,但如果有人有其他意见,我会感激不尽。

修改

所以当我开始使用它时,我意识到我仍然没有完全回答我自己的问题。虽然我有关于商品价格等的详细信息,但我无法获得productID,甚至不能获得UPC,ASIN,EAN,ISBN或其他任何内容,除非该商家信息有多个版本,在这种情况下,它可能用于区分说变种。我还不确定这是否可行,如果是,为什么它在eBay的API帮助中没有更突出的特色。

1 个答案:

答案 0 :(得分:1)

据我所知,这应该是ePN文档中的第一件事,因此在这里发布问答。我花了很多时间看着Product API和Finding API,然后才意识到这是你需要能够找到购物者的东西。

您可以使用易趣购物API的GetSingleItem方法获取此信息。这只需要知道ItemID,它可以在URL中找到。在示例中,它是斜杠后面的数字,但是有一些不同的URL格式,因此最好匹配10位数的正则表达式匹配。

一旦你有了这个请求很简单,例如http://open.api.ebay.com/shopping?callname=GetSingleItem&itemId=322028146082&appid=[YOUR_APP_ID]&version=515会给你:

<?xml version="1.0" encoding="UTF-8"?>
<GetSingleItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
    <Timestamp>2016-03-04T14:43:46.784Z</Timestamp>
    <Ack>Success</Ack>
    <Build>E949_CORE_APILW_17769283_R1</Build>
    <Version>949</Version>
    <Item>
        <ItemID>322028146082</ItemID>
        <EndTime>2016-04-03T13:41:26.000Z</EndTime>
        <ViewItemURLForNaturalSearch>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURLForNaturalSearch>
        <ListingType>FixedPriceItem</ListingType>
        <Location>Kings Mountain, North Carolina</Location>
        <GalleryURL>http://thumbs3.ebaystatic.com/pict/3220281460828080_1.jpg</GalleryURL>
        <PictureURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</PictureURL>
        <PictureURL>http://i.ebayimg.com/00/s/MTYwMFg5NDM=/z/l8sAAOSwpzdWsVie/$_1.JPG?set_id=8800005007</PictureURL>
        <PrimaryCategoryID>171228</PrimaryCategoryID>
        <PrimaryCategoryName>Books:Fiction &amp; Literature</PrimaryCategoryName>
        <BidCount>0</BidCount>
        <ConvertedCurrentPrice currencyID="USD">12.5</ConvertedCurrentPrice>
        <ListingStatus>Active</ListingStatus>
        <TimeLeft>P29DT22H57M40S</TimeLeft>
        <Title>Harry Potter and the Deathly Hallows 7 by J. K. Rowling (2007, 1st Edition)</Title>
        <Country>US</Country>
        <AutoPay>true</AutoPay>
    </Item>
</GetSingleItemResponse>

如果您需要更多信息,那么有交易API,这有点复杂。为此,您必须在https://api.ebay.com/ws/api.dll

上发出XML或SOAP POST请求

标题是这样的:

X-EBAY-API-COMPATIBILITY-LEVEL: 949
X-EBAY-API-APP-NAME: [YOUR_APP_ID]
X-EBAY-API-DEV-NAME: [YOUR_DEV_ID]
X-EBAY-API-CERT-NAME: [YOUR_CERT_ID]
X-EBAY-API-CALL-NAME: GetItem
X-EBAY-API-SITEID: 0

身体是这样的:

<?xml version="1.0" encoding="utf-8"?>
<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
    <RequesterCredentials>
        <eBayAuthToken>[YOUR_AUTH_TOKEN]</eBayAuthToken>
    </RequesterCredentials>
    <ItemID>322028146082</ItemID>
</GetItemRequest>

提交这个应该给你一个像:

的身体
<?xml version="1.0" encoding="UTF-8"?>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
    <Timestamp>2016-03-04T16:40:00.981Z</Timestamp>
    <Ack>Success</Ack>
    <Version>949</Version>
    <Build>E949_CORE_API_17775483_R1</Build>
    <Item>
        <AutoPay>true</AutoPay>
        <BuyerProtection>ItemIneligible</BuyerProtection>
        <BuyItNowPrice currencyID="USD">0.0</BuyItNowPrice>
        <Country>US</Country>
        <Currency>USD</Currency>
        <GiftIcon>0</GiftIcon>
        <HitCounter>NoHitCounter</HitCounter>
        <ItemID>322028146082</ItemID>
        <ListingDetails>
            <Adult>false</Adult>
            <BindingAuction>false</BindingAuction>
            <CheckoutEnabled>true</CheckoutEnabled>
            <ConvertedBuyItNowPrice currencyID="USD">0.0</ConvertedBuyItNowPrice>
            <ConvertedStartPrice currencyID="USD">12.5</ConvertedStartPrice>
            <HasReservePrice>false</HasReservePrice>
            <StartTime>2016-03-04T13:41:26.000Z</StartTime>
            <EndTime>2016-04-03T13:41:26.000Z</EndTime>
            <ViewItemURL>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURL>
            <HasUnansweredQuestions>false</HasUnansweredQuestions>
            <HasPublicMessages>false</HasPublicMessages>
            <ViewItemURLForNaturalSearch>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURLForNaturalSearch>
        </ListingDetails>
        <ListingDuration>Days_30</ListingDuration>
        <ListingType>FixedPriceItem</ListingType>
        <Location>Kings Mountain, North Carolina</Location>
        <PaymentMethods>PayPal</PaymentMethods>
        <PrimaryCategory>
            <CategoryID>171228</CategoryID>
            <CategoryName>Books:Fiction &amp; Literature</CategoryName>
        </PrimaryCategory>
        <PrivateListing>false</PrivateListing>
        <Quantity>1</Quantity>
        <ReviseStatus>
            <ItemRevised>true</ItemRevised>
        </ReviseStatus>
        <Seller>
            <AboutMePage>false</AboutMePage>
            <Email>Invalid Request</Email>
            <FeedbackScore>82</FeedbackScore>
            <PositiveFeedbackPercent>0.0</PositiveFeedbackPercent>
            <FeedbackPrivate>false</FeedbackPrivate>
            <FeedbackRatingStar>Blue</FeedbackRatingStar>
            <IDVerified>false</IDVerified>
            <eBayGoodStanding>true</eBayGoodStanding>
            <NewUser>false</NewUser>
            <RegistrationDate>2007-05-30T12:11:34.000Z</RegistrationDate>
            <Site>US</Site>
            <Status>Confirmed</Status>
            <UserID>westbrandbooks</UserID>
            <UserIDChanged>false</UserIDChanged>
            <UserIDLastChanged>2016-02-02T14:57:13.000Z</UserIDLastChanged>
            <VATStatus>NoVATTax</VATStatus>
            <SellerInfo>
                <AllowPaymentEdit>true</AllowPaymentEdit>
                <CheckoutEnabled>true</CheckoutEnabled>
                <CIPBankAccountStored>false</CIPBankAccountStored>
                <GoodStanding>true</GoodStanding>
                <LiveAuctionAuthorized>false</LiveAuctionAuthorized>
                <MerchandizingPref>OptIn</MerchandizingPref>
                <QualifiesForB2BVAT>false</QualifiesForB2BVAT>
                <StoreOwner>false</StoreOwner>
                <SafePaymentExempt>false</SafePaymentExempt>
            </SellerInfo>
            <MotorsDealer>false</MotorsDealer>
        </Seller>
        <SellingStatus>
            <BidCount>0</BidCount>
            <BidIncrement currencyID="USD">0.0</BidIncrement>
            <ConvertedCurrentPrice currencyID="USD">12.5</ConvertedCurrentPrice>
            <CurrentPrice currencyID="USD">12.5</CurrentPrice>
            <MinimumToBid currencyID="USD">12.5</MinimumToBid>
            <QuantitySold>0</QuantitySold>
            <ReserveMet>true</ReserveMet>
            <SecondChanceEligible>false</SecondChanceEligible>
            <ListingStatus>Active</ListingStatus>
            <QuantitySoldByPickupInStore>0</QuantitySoldByPickupInStore>
        </SellingStatus>
        <ShippingDetails>
            <ApplyShippingDiscount>false</ApplyShippingDiscount>
            <CalculatedShippingRate>
                <WeightMajor measurementSystem="English" unit="lbs">0</WeightMajor>
                <WeightMinor measurementSystem="English" unit="oz">0</WeightMinor>
            </CalculatedShippingRate>
            <SalesTax>
                <SalesTaxPercent>0.0</SalesTaxPercent>
                <ShippingIncludedInTax>false</ShippingIncludedInTax>
            </SalesTax>
            <ShippingServiceOptions>
                <ShippingService>ShippingMethodStandard</ShippingService>
                <ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost>
                <ShippingServicePriority>1</ShippingServicePriority>
                <ExpeditedService>false</ExpeditedService>
                <ShippingTimeMin>1</ShippingTimeMin>
                <ShippingTimeMax>6</ShippingTimeMax>
                <FreeShipping>true</FreeShipping>
            </ShippingServiceOptions>
            <ShippingType>Flat</ShippingType>
            <ThirdPartyCheckout>false</ThirdPartyCheckout>
            <ShippingDiscountProfileID>0</ShippingDiscountProfileID>
            <InternationalShippingDiscountProfileID>0</InternationalShippingDiscountProfileID>
            <SellerExcludeShipToLocationsPreference>true</SellerExcludeShipToLocationsPreference>
        </ShippingDetails>
        <ShipToLocations>US</ShipToLocations>
        <Site>US</Site>
        <StartPrice currencyID="USD">12.5</StartPrice>
        <TimeLeft>P29DT21H1M26S</TimeLeft>
        <Title>Harry Potter and the Deathly Hallows 7 by J. K. Rowling (2007, 1st Edition)</Title>
        <HitCount>6</HitCount>
        <LocationDefaulted>true</LocationDefaulted>
        <GetItFast>false</GetItFast>
        <BuyerResponsibleForShipping>false</BuyerResponsibleForShipping>
        <PostalCode>28086</PostalCode>
        <PictureDetails>
            <GalleryType>Gallery</GalleryType>
            <GalleryURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</GalleryURL>
            <PhotoDisplay>None</PhotoDisplay>
            <PictureURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</PictureURL>
            <PictureURL>http://i.ebayimg.com/00/s/MTYwMFg5NDM=/z/l8sAAOSwpzdWsVie/$_1.JPG?set_id=8800005007</PictureURL>
        </PictureDetails>
        <DispatchTimeMax>3</DispatchTimeMax>
        <ProxyItem>false</ProxyItem>
        <BuyerGuaranteePrice currencyID="USD">20000.0</BuyerGuaranteePrice>
        <IntangibleItem>false</IntangibleItem>
        <ReturnPolicy>
            <ReturnsAcceptedOption>ReturnsNotAccepted</ReturnsAcceptedOption>
            <ReturnsAccepted>No returns accepted</ReturnsAccepted>
        </ReturnPolicy>
        <ConditionID>4000</ConditionID>
        <ConditionDescription>Book is used but in good shape. May contain scribbles and/or notes in the margins.</ConditionDescription>
        <ConditionDisplayName>Very Good</ConditionDisplayName>
        <PostCheckoutExperienceEnabled>false</PostCheckoutExperienceEnabled>
        <ShippingPackageDetails>
            <ShippingIrregular>false</ShippingIrregular>
            <ShippingPackage>PackageThickEnvelope</ShippingPackage>
            <WeightMajor measurementSystem="English" unit="lbs">0</WeightMajor>
            <WeightMinor measurementSystem="English" unit="oz">0</WeightMinor>
        </ShippingPackageDetails>
        <RelistParentID>321997285555</RelistParentID>
        <HideFromSearch>false</HideFromSearch>
        <eBayPlus>false</eBayPlus>
        <eBayPlusEligible>false</eBayPlusEligible>
    </Item>
</GetItemResponse>