skip to Main Content

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

Answers


  1. 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
    
    Login or Signup to reply.
  2. Add &responseencoding=XML to the end or the URL.

    Login or Signup to reply.
  3. Q: What’s wrong with JSON ;)?

    In answer to your question:

    http://developer.ebay.com/devzone/finding/Concepts/MakingACall.html

    By default, the call response for XML requests is in XML format, but
    you can specify NV or JSON as a response format, if desired.

    Here’s an example from EBay’s web page:

    http://svcs.ebay.com/services/search/FindingService/v1?
       OPERATION-NAME=findItemsByKeywords
       &SERVICE-VERSION=1.0.0
       &SECURITY-APPNAME=YourAppID
       &RESPONSE-DATA-FORMAT=XML
       &REST-PAYLOAD
       &keywords=harry%20potter%20phoenix
    

    And here’s your example:

    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
    

    The most significant difference appears to be your callback. SUGGESTION: lose it!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search