Professional Documents
Culture Documents
ProgrammersGuide 10
ProgrammersGuide 10
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.com | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide
eBay Acellerator Toolkit for PHP
Unified Schema, EbatNs 1.0
InTradeSys Limited - Niederlassung Deutschland | Dillenburger Str. 75 | D - 51105 Köln | Geschäftsführer: Carsten
Harnisch | Steuernummer: 218/5720/1109 | Bankverbindung: Dresdner Bank AG Filiale Bonn | Konto: 01 769 212 00
BLZ: 370 800 40 | SWIFT-BIC: DRES DE FF 380 | IBAN: DE03 3708 0040 0176 9212 00 | HRB 53992
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
1 Introduction
The eBay Acellerator Toolkit New Schema (EbatNs) is the next step in programming the eBay API with PHP.
It is the suceessor of the eBay Acellerator Toolkit (ebat) for the legacy schema that already exists since
2003.
The toolkit gives you a kind of SDK for usage in PHP application on the webserver and/or the command line.
2 Installation
To install the EbatNs you will need a fully functional PHP installation on your system. Please first download
the package and unzip it. The package will be placed in a folder named “EbatNs” – please do not neither
rename the folder nor change the content of the folder. Although the name of the package is not really rele-
vant, any provided samples are relying on this configuration.
Be sure to place the folder somewhere within your PHP include_path. This might be a direct copy or prefer-
able a symbolic-link (if your OS supports it).
Some hosted environment does not gives you the ability to alter the include_path nor gives you direct access
to it. In such cases please use the procedure described under “Altering include_path”.
Here we assume that you place the Toolkit files directly under your www-root directory (so
/var/www/EbatNs). Any the code above will only work on Unix. Please refer to the samples directory
“hosted_environment” for a full featured version.
Anyway in all cases the path-modification has to be done in all files you call as the path will be resetting on
every request.
2
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
3 First Steps
3.1 Join the eBay Developer-Program
To use any of the eBay-API-Calls you will have to have an account in the eBay developer program. As a
result you will get a key-triple which identifies you as a developer.
For will get a key-triple for the so called “sandbox” right after you joined the program. After testing you can
switch to the production system will.
Register first to the developer program at http://developer.ebay.com. After going through the process you will
receive 3 keys (DevId, AppId and CertId) all for sandbox access. The sandbox is the eBay testing system for
the developers. Please save the 3 keys you will later store them to the configuration-file.
3
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
the same fact regarding the token-file. Here the extension .token is used by default, so the file can be
downloaded if someone know the path and exact file-name !!!
Please insert into these files the information you collected before:
site-id=0
app-mode=1
token-mode=1
token-pickup-file=/path/sandbox.token
(please enter the file name where you stored the token)
3.5 Samples
The first sample should run now, try „getTime.php“. We will provide with much more sample over the time.
4
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
4 Basic Operations
To issue a call to the eBay API you will need a Session. Then create a ServiceProxy with the Session. The
parameters of a call are always given in a call-specific Request-Object. The ServiceProxy will have a PHP-
Method for all known API-call that takes the Request as a parameter and returns the call-specific Response-
Object.
4.1 Proxy, Session
You first lets create a Session and a ServiceProxy.
require_once 'EbatNs_ServiceProxy.php';
$session = new EbatNs_Session('/config/ebay.config.php');
$sp = new EbatNs_ServiceProxy($session);
The Session could take a path to the config-file to initialize all needed information form it.
There is also a short-version to let the ServiceProxy create the session for you. Here you only give the con-
fig-file.
$sp = new EbatNs_ServiceProxy($cfg = '/config/ebay.config.php');
Note: The ServiceProxy will take a reference-parameter, so you will need this rarely used syntax here. So
the method can distinguish weather you passed a session or the config-file.
The Request-Type might (normally) need various data to be set. Here as we want to retrieve an Item we only
need to set the ItemID. Within the EbatNs you will find “setter”-methods for all parameters you can use.
Note: You might get back data here as the Item above with the ID 4504181935 might be already expired
when you do the call.
Next you can issue the call :
$res = $cs->GetItem($req);
Easy doing you will get back the response with the Item you are interested in.
Next you can check the Response and retrieve the information of interest. In this case we can just print out
the item.
echo "<pre>";
print_r($res->getItem());
5
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
Also the Response Object will have methods to access the data. Here you will find “getter”-methods for all
data.
Note: Please take care that not all data is returned by all calls. The eBay Unified Schema might define data
for various type that is only returned under certain circumstances.
Ok, here is the complete script altogether :
require_once 'EbatNs_ServiceProxy.php';
require_once 'GetItemRequestType.php';
$session = new EbatNs_Session('/config/ebay.config.php');
$sp = new EbatNs_ServiceProxy($session);
$req = new GetItemRequestType();
$req->setItemID(4504181935);
$res = $cs->GetItem($req);
echo "<pre>";
print_r($res->getItem());
Here you can also retrieve the Errors-Array and show the error you got :
foreach ($res->getErrors() as $error)
{
echo "#" . $error->getErrorCode()
. " " . htmlentities($error->getShortMessage())
. "/" . htmlentities($error->getLongMessage()) . "<br>";
}
6
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
As all stuff could be found here we skipped a documentation of the Toolkit and you should relate to the docs
above. Be sure that you relate to the documentation version of the Toolkit you are using.
For all API-calls (found under API Call Reference Guide) you will find a method in the ServiceProxy and the
request/response datatypes. All schema datatype will correlate to a PHP file that implements the datatype.
We have made minimal adoption to the way to eBay Schema datatypes are transferred to PHP objects. You
can find details within the following paragraphs.
Note: We had integrated comments within the EbatNs code to let an intelligent IDE use this information and
provide you with some hints while programming. You can use a documentor on this information and gener-
ate a help file (checkout http://www.phpdoc.de/).
7
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
6 Data Structure
The eBay Acellerator for PHP Unified Schema is using SOAP calls to communicate with eBay API Servers.
When starting with the project we saw a lot of different SOAP implementations on PHP (NuSoap, PEAR-
SOAP, etc.). As none of them really fitted our needs we just rewrote our own implementation. Definitely our
SOAP client is not tested with others than the eBay WebService and we assume it should not a good idea to
use it for other purposes. But it is rather light-weight and so the performance should not be an issue.
What was basically done her is a kind of type-aware DOM parsing but without using the PHP DOM Libraries
but only the “normal” XML (Expat) parser that PHP is providing as a internal module. So you will get PHP
objects with member-variables, in case of arrays these variables are just PHP arrays. The underlying E-
batNs_Parser will include any needed PHP class-files if needed, so the resulting object-structure should be
very clean.
6.1 Basic Mapping
As a basic guideline all eBay Schema datatypes are mapped against single PHP files which you can find in
the EbatNs installation folder. For each call you will find a file corresponding to the Request and Response
datatype. The files will auto-include any needed sub-types that are used within here.
The implementation of the datatypes in PHP are based on PHP-classes. For any child-elements these clas-
ses implements a member-variable with the same name. All variables could be either accessed directly or
via provided getter- and setter-methods.
If the Schema datatype is a “simple-type” we provided a member-variable which is named “value” and a set-
TypeValue($value) and getTypeValue() method (see EbatNs_SimpleType.php for details).
Most of the Schema datatype do not have XML-Attributes but a few do (e.g. the AmountType). Here you can
use the provided methods setTypeAttribute( $key, $value ) and getTypeAttribute( $key ) to access the Attrib-
utes. Sounds very complex but in reality it is not. PHP is very “type-lax” so we thought the best way was to
do it like this.
Let’s setup a basic AddItemRequestType to see the implications to code:
$item = new ItemType();
$item->ListingDuration = ‘Days_7’;
$item->StartPrice = new AmountType();
$item->StartPrice->setTypeValue(3.99);
$item->StartPrice->setTypeAttribute(‘currencyID’, ‘EUR’);
$item->BuyItNowPrice = new AmountType();
$item->BuyItNowPrice->setTypeValue(9.99);
$item->BuyItNowPrice->setTypeAttribute(‘currencyID’, ‘EUR’);
…
$req = new AddItemRequestType();
$req->Item = $item;
8
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
Leaving out the $index argument will set/get the internal array itself (so all elements). Although all of this
seems easy and obvious you might trigger some problems here as the API docs does not directly points you
to the cardinality (anyway it is in the WSDL and Visual Schema Reference).
6.1.2 Setter- and Getter-methods
For all Schema object the appropriate access methods are generated. The names are just prefixed by “get”
and “set”.
Schema:
Item.ListingDuration
9
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
If an element is an array you will get extra arguments $index to access the indexed values. Beware that lea-
ving the argument out will result to access the internal array, but a single value.
Setting array-type values:
$paymentMethods[] = ‘PersonalCheck’;
$paymentMethods[] = ‘MoneyXferAccepted’;
$paymentMethods[] = ‘PayPal’;
// setting the array as a value
$item->setPaymentMethods($paymentMethods);
or
// setting the values one by one
$item->setPaymentMethods($paymentMethods[0], 0);
$item->setPaymentMethods($paymentMethods[1], 1);
$item->setPaymentMethods($paymentMethods[2], 2);
$item->setPaymentMethods(‘COD’, 3);
would throw this if the item you work on does not have ShippingTerms :
Notice: Undefined property: ShippingTerms in ../ItemType.php on line xxx
You should then switch off error_reporting for E_NOTICE (which is the default on PHP 4) or test the value
first.
6.1.4 Data Conversion
The EbatNs will do data conversion internally. As SOAP and PHP differs in the way certain data types are
coded we did some internal conversion here. Besides you would like to work in your scripts not using UTF-8
Charset Encoding (what is needed for the eBay API) but using PHP’s ISO-8859-1 charset.
10
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
We placed DataConversion into a separate class called EbatNs_DataConverter. Here you will find handler
method for encoding and decoding data. You might decide to re-model the DataConverter for your needs.
IMPORTANT NOTE : Currently the EbatNs_ServiceProxy is using a DataConverterIso as default
which will encode/decode to ISO-8859-1. So any string sended will be encoded using utf8_encode
and any strings coming back will be decoded using utf8_decode. Besides this the field “Description”
is always placed into a <![CDATA[ ]]> construct.
11
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
7 Advanced Operations
7.1 Working with Pagination
A few API call have the ability to retrieve data in data-page so you can retrieve the returned data in chunk
(the so called pages) giving a page-size and a page-number.
The unified schema does simplified the procedure using the PaginationType. Please following the code be-
low to clarify the way it works.
$cs = new EbatNs_ServiceProxy($session);
$req = new GetPopularKeywordsRequestType();
// getting chunk of page-size 100 ...
// ... and current page 1
$req->Pagination = new PaginationType();
$req->Pagination->EntriesPerPage = 100;
$req->Pagination->PageNumber = 1;
$res = $cs->GetPopularKeywords($req);
Anyway what you get back in $res will depend on the notification that is handled. Anyway you check in the
fields NotificationEventName, NotificationSignature and RecipientUserID for the notification informational
data.
12
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
8 Special EbatNs-Features
8.1 Using a DataType-Handler
Depending on the amount and way you would like to handle the returned data you might use the “DataType-
Handler”-feature of the EbatNs.
Basically you hook into the parsing process of the ResponseParser and will be notify if a certain Element
was parsed. The hook is based on the Type of object that needs to be stored. Normally the parser would just
attach the data within the structure (ResponseObject) and returns all data as a return of the call.
Especially if you have to handle of large amount of data (e.g. a category-download) this way would create a
very large response-object. So the script would consume a lot of memory and resources. Anyway afterwards
you would go and loop the response-data and handle it.
The way the DataType-handler works will make the procedure much easier and normally you can work with
a much lower memory-limit.
So setup a handler you will need a callback-function (either a global function or an object’s method). You will
then inform the ServiceProxy about the handler and the DataType is should work on. Within your handler
you can decide weather you like to attach the parsed object to the result or not.
The function signature has to be like this :
function callback($type, & $data)
{
return true;
}
The function handleItem will be called on each Item retrieved. Returning false in the function will let the par-
ser attach the Item to the response. If you return true the Item would NOT be attached.
Anyway the same functionality could also be done using an object as the handler. Here is a sample for a
category-download.
13
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
14
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
9 Appendix
9.1 Cookbook
The cookbook lists ready-made scripts for usage in standard-situations. This should guide beginners as a
starting point to the usage of the EbatNs.
Most of the following script could also be found in the addional sample pack. Before you try to integrate the
snipple be sure that the the EbatNs-Folder is within your include path and that you have access to specifc
config-file
$res = $cs->GetCategories($req);
class handlerMethods
{
// import-need to pass in by ref !
function handlerMethods(& $cs) {
$cs->setHandler('CategoryType', array(& $this, 'handleCategory'));
}
return true;
}
}
?>
15
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$item->Site = 'Germany';
$item->ShipToLocations[]="Europe";
16
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$InternationalShippingServiceOptions-
>setShippingService('DE_VersicherterVersandInternational');
$InternationalShippingServiceOptions->setShippingServiceCost(4.44);
$InternationalShippingServiceOptions->setShippingServicePriority(1);
$InternationalShippingServiceOptions->setShipToLocation('Europe');
$shippingInternational[]=$InternationalShippingServiceOptions;
$shippingObj->setShippingServiceOptions($shipping, 0);
$shippingObj->setInternationalShippingServiceOption($InternationalShippingServiceOptions,
0);
$item->setPaymentMethods($Facet_BuyerPaymentMethodCodeType->PaymentSeeDescription, 2);
$item->setPaymentMethods($Facet_BuyerPaymentMethodCodeType->COD, 3);
$item->setPaymentMethods($Facet_BuyerPaymentMethodCodeType->PayPal, 4);
$item->setPayPalEmailAddress('paypal@intradesys.com');
$item->setShippingDetails($shippingObj,0);
echo "<pre>";
print_r($res);
?>
9.1.2.2 list with attributes
<?php
require_once 'EbatNs/EbatNs_ServiceProxy.php';
require_once 'EbatNs/EbatNs_Logger.php';
require_once 'EbatNs/VerifyAddItemRequestType.php';
require_once 'EbatNs/AddItemRequestType.php';
require_once 'EbatNs/ItemType.php';
17
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$item->PaymentMethods[] = $Facet_BuyerPaymentMethodCodeType->MoneyXferAccepted;
$item->PaymentMethods[] = $Facet_BuyerPaymentMethodCodeType->PayPal;
$item->PayPalEmailAddress = 'paypal@intradesys.com';
18
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$att->setTypeAttribute('attributeID', 3806);
19
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$condAttSet->Attribute[] = $condAtt;
$item->ShipToLocations[]="Europe";
$shippingObj->setShippingServiceOptions($shipping, 0);
$item->setShippingDetails($shippingObj,0);
}
echo "<pre>";
20
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
print_r($res);
?>
9.1.2.3 list to real-estate category (germany)
<?php
require_once 'EbatNs/EbatNs_ServiceProxy.php';
require_once 'EbatNs/EbatNs_Logger.php';
require_once 'EbatNs/AddItemRequestType.php';
require_once 'EbatNs/ItemType.php';
$item->Site = 'Germany';
// objekt-subtyp : Neubau
21
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
// bundesland : NRW
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 9);
$val = new ValType();
$val->setValueID(26801);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stadt : Köln
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 10);
$val = new ValType();
$val->setValueID(26896);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stadtteil : poll
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27775);
$val = new ValType();
$val->setValueID(29389);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// anzahl-zimmer : 4
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 29);
$val = new ValType();
$val->setValueLiteral('4');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stockwerk : 3
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27783);
$val = new ValType();
$val->setValueID(32472);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// qm : 150
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27776);
22
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
// NK : 111
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27784);
$val = new ValType();
$val->setValueLiteral('111');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// miete : 666
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 30249);
$val = new ValType();
$val->setValueLiteral('666');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// kaution : 3 mm
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32462);
$val = new ValType();
$val->setValueLiteral('1998');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// provision : 1 mm
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32463);
$val = new ValType();
$val->setValueLiteral('666');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// baujahr : 2000
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 30737);
$val = new ValType();
$val->setValueLiteral('2000');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// verfügbar : 01.03.2006
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32464);
$val = new ValType();
$val->setValueLiteral('2006-03-01');
23
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
$attSet->Attribute[] = $att;
$atts->setAttributeSet($attSet, 0);
$item->AttributeSetArray = $atts;
$req->Item = $item;
$res = $cs->AddItem($req);
echo "<pre>";
print_r($res);
?>
9.1.3 Retrieve a single item
9.1.3.1 Simple GetItem:
<?php
require_once 'EbatNs/EbatNs_ServiceProxy.php';
require_once 'EbatNs/EbatNs_Logger.php';
require_once 'EbatNs/GetItemShippingRequestType.php';
$res = $cs->GetItemShipping($req);
24
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
print_r($res);
?>
9.1.3.2 Full-Featured GetItem:
<?php
error_reporting(E_ALL ^ E_NOTICE);;
require_once 'EbatNs/EbatNs_ServiceProxy.php';
require_once 'EbatNs/EbatNs_Logger.php';
require_once 'EbatNs/GetItemRequestType.php';
require_once 'EbatNs/ItemType.php';
$res = $cs->GetItem($req);
echo "<pre>";
if ($res->getAck() != $Facet_AckCodeType->Success)
{
echo "we got a failure<br>";
foreach ($res->getErrors() as $error)
{
echo "#" . $error->getErrorCode() . " " .
htmlentities($error->getShortMessage()) . "/" .
htmlentities($error->getLongMessage()) . "<br>";
}
}
else
{
$item = $res->getItem();
25
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$listDet = $item->ListingDetails;
echo $listDet->ViewItemURL . "<br>";
echo "2nd Variation direkt: " .
$res->Item->ListingDetails->ViewItemURL . "<br>";
}
$item->ItemID = "4504789605";
26
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
// wohnen
$item->PrimaryCategory->CategoryID = 60092;
$item->Site = 'Germany';
// objekt-subtyp : Maisonette
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 26819);
$val = new ValType();
$val->setValueID(-6);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// bundesland : NRW
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 9);
$val = new ValType();
$val->setValueID(26801);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stadt : Köln
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 10);
$val = new ValType();
$val->setValueID(26896);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stadtteil : poll
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27775);
$val = new ValType();
$val->setValueID(29389);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// anzahl-zimmer : 4
$att = new AttributeType();
27
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$att->setTypeAttribute('attributeID', 29);
$val = new ValType();
$val->setValueLiteral('5');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// stockwerk : 3
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27783);
$val = new ValType();
$val->setValueID(32472);
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// qm : 150
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27776);
$val = new ValType();
$val->setValueLiteral('200');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// NK : 111
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 27784);
$val = new ValType();
$val->setValueLiteral('120');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// miete : 666
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 30249);
$val = new ValType();
$val->setValueLiteral('888');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// kaution : 3 mm
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32462);
$val = new ValType();
$val->setValueLiteral('2500');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// provision : 1 mm
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32463);
$val = new ValType();
28
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$val->setValueLiteral('1000');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// baujahr : 2000
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 30737);
$val = new ValType();
$val->setValueLiteral('1999');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
// verfügbar : 01.03.2006
$att = new AttributeType();
$att->setTypeAttribute('attributeID', 32464);
$val = new ValType();
$val->setValueLiteral('2006-05-01');
$att->setValue($val, 0);
$attSet->Attribute[] = $att;
$attSet->Attribute[] = $att;
$atts->setAttributeSet($attSet, 0);
$item->AttributeSetArray = $atts;
$req->Item = $item;
$res = $cs->ReviseItem($req);
echo "<pre>";
print_r($res);
?>
29
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
$now = time();
$start = $now - (3600 * 24 * 30);
$end = $start + (3600 * 24 * 30);
// period 30 days
$req->ModTimeFrom = gmdate('Y-m-d H:i:s', $start);
$req->ModTimeTo = gmdate('Y-m-d H:i:s', $end);
$req->DetailLevel = $Facet_DetailLevelCodeType->ReturnAll;
$res = $cs->GetItemTransactions($req);
echo "<pre>";
print_r($res);
?>
9.1.5.2 Using GetSellerTransactions:
<?php
require_once 'EbatNs/EbatNs_ServiceProxy.php';
require_once 'EbatNs/EbatNs_Logger.php';
require_once 'EbatNs/GetSellerTransactionsRequestType.php';
require_once 'EbatNs/GetSellerTransactionsResponseType.php';
$now = time();
$start = $now - (3600 * 24 * 30);
$end = $start + (3600 * 24 * 30);
// period 30 days
$req->ModTimeFrom = gmdate('Y-m-d H:i:s', $start);
$req->ModTimeTo = gmdate('Y-m-d H:i:s', $end);
$req->DetailLevel = $Facet_DetailLevelCodeType->ReturnAll;
30
_________________________________
________________________________ ________________
________________ __
__ _______
_______ ___
___ ________
_______
www.intradesys.de | ebat@intradesys.com
________________________________
________________________________ ________________ IN
________________ __ TR ADES
__ _______
_______ YS________
___
___ ________
Programmers Guide, EbatNs, 1.0
if ($res->Ack == $Facet_AckCodeType->Success)
{
echo "<pre>";
print_r($res);
}
?>
31