I need more understanding of how the eBay API works

I looked at a lot of examples in PHP codes on this site, BUT they continue to use different methods every time, and it's not easy at all! I downloaded the ebaySession.php and keys.php files. I successfully integrated the ebaysession class and made contact with ebay. But how to use the sendHttpRequest () method confuses me. There is no explanation of how to get user account information.

Many tutorials also show that the constructor for the eBaySession class has a request token as the last parameter, while my file has a user token as the first parameter. There are many inconsistencies with the eBay API documentation. I have a test user account with a token in place ...

I also don't understand why the eBaySession constructor requires a UserToken & callname when in the ebay examples the call name and usertoken were included in the XML string ...

A SIMPLE question to which I do not see a clear answer in eBay docs: how can I make a simple call and then get the results / answer in a variable? I achieved this with a simple search query, but I can’t get it to work when user information and authentication are required ... ALSO the search example that eBay had was using a request like URL, for example

// Construct the findItemsByKeywords HTTP GET call $apicall = "$endpoint?"; $apicall .= "OPERATION-NAME=findItemsByKeywords"; $apicall .= "&SERVICE-VERSION=$version"; $apicall .= "&SECURITY-APPNAME=$appid"; $apicall .= "&GLOBAL-ID=$globalid"; $apicall .= "&keywords=$safequery"; 

Then another example uses:

 ///Build the request Xml string $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>'; $requestXmlBody .= '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">'; $requestXmlBody .= "<SessionID>$theID</SessionID>"; $requestXmlBody .= '</FetchTokenRequest>'; 

This XML code has been placed in the sendHttpRequest () method. What for? there was another example that did the same thing where authToken was inside XML, but authToken was defined in the constructor of the class ...

Any general advice on using the PHP eBay API will be greatly appreciated.

+4
source share
2 answers

GetUser Will returns user data for one user. See below for a good guide for this.

http://developer.ebay.com/devzone/xml/docs/reference/ebay/getuser.html

+2
source

You ask so many questions that it’s hard to follow and answer everything. The best suggestion I have is to use the eBay SDK for PHP. You can find it here . This will make your life a lot easier and it will return the whole answer in a variable as you want.

You will make this call:

 $service = new TradingServices\TradingService([ 'credentials' => [ 'devId' => 'YOUR_DEV_ID', 'appId' => 'YOUR_APP_ID', 'certId' => 'YOUR_CERT_ID', ], 'siteId' => YOUR_SITE_ID, 'sandbox' => false // or true, 'token' => YOUR_TOKEN ]); $request = new TradingTypes\GetItemRequestType(); $request->ItemID = $your_itemid; $response = $service->GetItem($request); 

Then you have all the data you want in $response var, and you can get the specific data with

 $title = $response->Item->Title; $description = $response->Item->Description; ... 

I used this SDK to develop a platform from which I manage about 30k lists in 3 ebay stores, I make new lists, I control my sales in all 3 stores, I send and receive messages from all 3 stores, and so on.

It also has some very good examples, and this will make it easier to understand the eBay documentation.

So believe me, this is an extremely powerful tool that will make your development days much easier and help you work much faster.

0
source

Source: https://habr.com/ru/post/1346499/


All Articles