I'm using finding service has URL and it works fine, $url = '
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced'; $url .= '&SERVICE-NAME=FindingService&SERVICE-VERSION=1.0.0&GLOBAL-ID=EBAY-GB'; $url .= '&SECURITY-APPNAME=' . $appid . '&RESPONSE-DATA-FORMAT=XML'; $url .='&keywords=' . $itemnumber; I now need to call GetSingleItem $url2 = '
http://open.api.ebay.com/shopping?callname=GetSingleItem&responseencoding=XML&appid=' . $appid . '&siteid=0&version=967&ItemID=' . $itemnumber . "&IncludeSelector=Description,ItemSpecifics"; Both return success using $resp2 = file_get_contents($url2); but when i use $xml2 = new SimpleXMLElement($resp2); it returns a non object, how can i call the elements from resp2 for its details similar too $itemid = (string) $xml->searchResult->item->itemId; $shipcost = (string) $xml->searchResult->item->shippingInfo->shippingServiceCost;
Instead of using *new SimpleXMLElement()* , use [simplexml_load_string()] to convert the retrieved API data (a long string) to parsed XML. You should then be able to use code like *$itemid = (string) $xml->searchResult->item->itemId;* just fine. :
echo it and read, or file_put_contents to a file and open the file in a browser. In most cases, eBay will return a well formatted XML response with error messages if your request is incorrect. So you probably have a error in your PHP process somewhere. You have to show your complete code if you want help with that. Posting scraps of lines won't tell us much. If resp2 is ok, look at this page:
That's different than what you described before. You seem to be ignoring the 400 error occurring in file_get_contents. That means resp2 is bad. Can't tell why that's happening without the relevant code. But the URL is probably wrong (probably a space in there somewhere). Add one or both of the following before the file_get_contents line: echo "$url2
\n"; error_log($url2); That will show you the request URL actually being submitted to eBay. Fix the URL.
I have got rid of the errors, only thing now is how do i extract the quantity of that item? is it from xml2? when i use this method same as $url findItemsAdvanced i get a non object error $qty = (string) $xml2->searchResult->item->Quantity;
Since the Shopping API returns different data, it has a different format and doesn't return a searchResult node. Look at the docs or the XML response itself to determine where the data you need is located. Also, FWIW, if you already have the item number the call to findItemsAdvanced may not be necessary. GetSingleItem/GetMultiplItem return a lot of the same data. Depends on your needs.