ds211107 2013-04-23 21:39
浏览 47
已采纳

eBay API返回JSON而不是XML格式

I am trying to make a call to the eBay API and have the results returned in XML format (I am using PHP).

Upon making the following call or even navigating to this URL in a browser, the response is always returned in JSON, or some other funky format, never in XML:

http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=[removed-for-security]&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.12.0&RESPONSE-DATA-FORMAT=XML&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=$searchTerm&paginationInput.entriesPerPage=3

Any thoughts?

EDIT: This is what I'm receiving:

_cb_findItemsByKeywords({"findItemsByKeywordsResponse":[{"ack":["Success"],"version":["1.12.0"],"timestamp":["2013-04-23T21:41:13.474Z"],"searchResult":[{"@count":"3","item":[{"itemId":["261205412868"],"title":["Apple iPhone 4 - 32GB - Black (Unlocked) Smartphone"],"globalId":["EBAY-US"],"primaryCategory":[{"categoryId":["9355"],"categoryName":["Cell Phones & Smartphones"]}],"galleryURL":["http:\/\/thumbs1.ebaystatic.com\/m\/my0vy-RgnhVBALirMFhHCaA\/140.jpg"],"viewItemURL":["http:\/\/www.ebay.com\/itm\/Apple-iPhone-4-32GB-Black-Unlocked-Smartphone-\/261205412868?pt=Cell_Phones"],"productId":[{"@type":"ReferenceID","__value__":"99939964"}],"paymentMethod":["PayPal"],"autoPay":["false"],"postalCode":["97215"],"location":["Portland,OR,USA"],"country":["US"],"shippingInfo":[{"shippingServiceCost":[{"@currencyId":"USD","__value__":"0.0"}],"shippingType":["Free"],"shipToLocations":["US"],"expeditedShipping":["true"],"oneDayShippingAvailable":["false"],"handlingTime":["2"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"USD","__value__":"274.99"}],"convertedCurrentPrice":[{"@currencyId":"USD","__value__":"274.99"}],"sellingState":["Active"],"timeLeft":["P4DT23H13M47S"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2013-04-23T20:55:00.000Z"],"endTime":["2013-04-28T20:55:00.000Z"],"listingType":["FixedPrice"],"gift":["false"]}],"returnsAccepted":["false"],"condition":[{"conditionId":["3000"],"conditionDisplayName":["Used"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]},{"itemId":["111054473885"],"title":["Apple iPhone 3GS - 16GB Black (AT&T) Smartphone (MB715LL\/A) With Original Box"],"globalId":["EBAY-US"],"primaryCategory":[{"categoryId":["9355"],"categoryName":["Cell Phones & Smartphones"]}],"galleryURL":["http:\/\/thumbs2.ebaystatic.com\/m\/mVzC6dpqIgRKIzrUTKqH2SA\/140.jpg"],"viewItemURL":["http:\/\/www.ebay.com\/itm\/Apple-iPhone-3GS-16GB-Black-AT-T-Smartphone-MB715LL-A-Original-Box-\/111054473885?pt=Cell_Phones"],"productId":[{"@type":"ReferenceID","__value__":"101828989"}],"paymentMethod":["PayPal"],"autoPay":["false"],"postalCode":["13323"],"location":["Clinton,NY,USA"],"country":["US"],"shippingInfo":[{"shippingType":["Calculated"],"shipToLocations":["US"],"expeditedShipping":["true"],"oneDayShippingAvailable":["false"],"handlingTime":["2"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"USD","__value__":"73.0"}],"convertedCurrentPrice":[{"@currencyId":"USD","__value__":"73.0"}],"bidCount":["38"],"sellingState":["Active"],"timeLeft":["P0DT0H0M42S"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2013-04-16T21:41:55.000Z"],"endTime":["2013-04-23T21:41:55.000Z"],"listingType":["Auction"],"gift":["false"]}],"returnsAccepted":["false"],"condition":[{"conditionId":["3000"],"conditionDisplayName":["Used"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]},{"itemId":["111058640858"],"title":["Apple iPhone 4 - 16GB - Black (Verizon)"],"globalId":["EBAY-US"],"primaryCategory":[{"categoryId":["9355"],"categoryName":["Cell Phones & Smartphones"]}],"galleryURL":["http:\/\/thumbs3.ebaystatic.com\/m\/my0vy-RgnhVBALirMFhHCaA\/140.jpg"],"viewItemURL":["http:\/\/www.ebay.com\/itm\/Apple-iPhone-4-16GB-Black-Verizon-\/111058640858?pt=Cell_Phones"],"productId":[{"@type":"ReferenceID","__value__":"101787954"}],"paymentMethod":["PayPal"],"autoPay":["true"],"postalCode":["30213"],"location":["Fairburn,GA,USA"],"country":["US"],"shippingInfo":[{"shippingType":["Calculated"],"shipToLocations":["US"],"expeditedShipping":["true"],"oneDayShippingAvailable":["false"],"handlingTime":["2"]}],"sellingStatus":[{"currentPrice":[{"@currencyId":"USD","__value__":"150.0"}],"convertedCurrentPrice":[{"@currencyId":"USD","__value__":"150.0"}],"sellingState":["Active"],"timeLeft":["P2DT21H31M58S"]}],"listingInfo":[{"bestOfferEnabled":["false"],"buyItNowAvailable":["false"],"startTime":["2013-04-23T19:13:11.000Z"],"endTime":["2013-04-26T19:13:11.000Z"],"listingType":["FixedPrice"],"gift":["false"]}],"returnsAccepted":["false"],"condition":[{"conditionId":["3000"],"conditionDisplayName":["Used"]}],"isMultiVariationListing":["false"],"topRatedListing":["false"]}]}],"paginationOutput":[{"pageNumber":["1"],"entriesPerPage":["3"],"totalPages":["488589"],"totalEntries":["1465767"]}],"itemSearchURL":["http:\/\/www.ebay.com\/sch\/i.html?_nkw=iphone&_ddo=1&_ipg=3&_pgn=1"]}]})

Not sure what this is, as I've tried to validate it as JSON and it comes back saying it's not valid.

  • 写回答

3条回答 默认 最新

  • douzhanlie9209 2013-04-23 21:42
    关注

    The format you got is JSONP. Remove the &callback=_cb_findItemsByKeywords from the url. Then you'll get xml

    Here comes the url that gives you xml:

    http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=[removed-for-security]&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.12.0&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=$searchTerm&paginationInput.entriesPerPage=3
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?