question

oknoeu avatar image
0 Likes"
oknoeu asked

Problem connecting to Shopping API

Hello everybody!

I have a problem connecting to the Shopping API.

I am using the following code:


$sXml='<?xml version="1.0" encoding="utf-8"?>

<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">

<ItemID>174963807872</ItemID>

</GetSingleItemRequest>';


$headers =array(

'X-EBAY-API-IAF-TOKEN: '.$tokken,

'X-EBAY-API-APP-ID: '.$appid,

'X-EBAY-API-CALL-NAME: GetSingleItem',

'X-EBAY-API-VERSION: '.$version,

);


$sUrl='https://open.api.ebay.com/shopping';


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $sUrl);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

$result = curl_exec($ch);

The response from the server is empty. What am I doing wrong? What do I need to do to get product information?

shopping api
· 4
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks! I got item info in Postman but can't get info via php even though my code is identical. I got the following error:

Failure Input data is invalid. Input data for the given tag is invalid or missing. Please check API documentation. 1.22 Error 3; columnNumber: 15; XML document structures must start and end within the same entity. RequestError E1199_CORE_APILW_19146596_R1 1199


0 Likes 0 ·
postman generates php code for you on the fly, on the right side there is an icon "</>", try this and compare everything again. but the message sounds like something is wrong with your xml.


maybe this sdk is a help:


https://github.com/michabbb/php-ebay-sdk

0 Likes 0 ·
Show more comments
alvisinwales avatar image
0 Likes"
alvisinwales answered

Your XML looks OK.

I use these headers and it works fine:

-H "X-EBAY-API-Compatibility-LEVEL: 963"
-H "X-EBAY-API-CALL-NAME: GetSingleItem"
-H "X-EBAY-API-SITEID: 3"
-H "X-EBAY-API-IAF-TOKEN: v^1.1#i^...SrL3jnEQAA"
-H "X-EBAY-API-DETAIL-LEVEL: 0"
-H "X-EBAY-API-VERSION: 963"
-H "X-EBAY-API-REQUEST-ENCODING: XML"

Try experimenting with some of those.


· 2
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks,

When adding the header "X-EBAY-API-REQUEST-ENCODING: XML" I get the following error message:

"Failure Input data is invalid. Input data for the given tag is invalid or missing. Please check API documentation. 1.22 Error 3; columnNumber: 15; XML document structures must start and end within the same entity. RequestError E1199_CORE_APILW_19146596_R1 1199. "

0 Likes 0 ·
I can't explain that.

Can you get the actual curl command to check it.

Mine is:

C:\curl.exe
-k
"https://open.api.ebay.com/shopping"
-H "X-EBAY-API-Compatibility-LEVEL: 963"
-H "X-EBAY-API-CALL-NAME: GetSingleItem"
-H "X-EBAY-API-SITEID: 3"
-H "X-EBAY-API-IAF-TOKEN: v^1.1#i^...SrL3jnEQAA"
-H "X-EBAY-API-DETAIL-LEVEL: 0"
-H "X-EBAY-API-VERSION: 963"
-H "X-EBAY-API-REQUEST-ENCODING: XML"
-i
-d "@C:\XMLOUT_GETSINGLEITEM.txt"
-o C:\TEMPCURLOUT_211012080019289563.txt



0 Likes 0 ·
tristen_28 avatar image
-1 Like"
tristen_28 answered

In this case, the best, if not the only, way to set up an ongoing data interchange with the online store is to integrate with the shopping cart.

greatpeople.me

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.