If you have any question left, please drop a note with the discussion link of this page.
API Version 2009-07-01 Client
From Wiki.zanox.com
Requirements
The miniumum requirements are:
- PHP 5 >= 5.2.0
Installation
Download and install the PHP API client in your source code directory. In order to use the RESTful (XML/JSON) or the SOAP API you just need a working PHP5 enviroment.
Usage
Copy code examples and edit the code to use your connectId, publicKey and secredKey. The detailed documentation of the API client can be found inside of the source code and conforms to the PHPDoc standard.
Step 1: Include the zanox API client and create a class instance of either the XML, JSON or SOAP interface.
If you don't provide a protocol by default XML will be choosen. If you don't specify a API Version either the client always uses the latest version defined by the API Client. Please always try to specify a version or otherwise your code might break after upgrading to a new client version.
// include zanox API client require_once 'client/ApiClient.php'; // create a RESTful JSON interface instance $client = ApiClient::factory(PROTOCOL_JSON, VERSION_2009_07_01); // or create a RESTful XML interface instance $client = ApiClient::factory(PROTOCOL_XML, VERSION_2009_07_01); // or create a SOAP interface instance without version $client = ApiClient::factory(PROTOCOL_SOAP);
Step 2: Set up authentication credentials
Please replace the connectId, the publicKey and the secretKey with your credentials from the application store. In case you use the API just for your own purposes please create a new application in the application store. By creating this application for your own usage you will receive a connectId and the other authentication credentials.
$connectId = '__your_connect_id__'; $publicKey = '__your_public_key__'; $secretKey = '__your_secrect_key__'; $client->setConnectId($connectId); $client->setSecretKey($secretKey); $client->setPublicKey($publicKey);
Step 3 (optional): Set up proxy server and HTTP Protocol
Additionally you can tell the client library to use a proxy server on API requests as well as to use HTTP or HTTPS.
// use secure HTTPS $api->setHttpProtocol(HTTPS); // use HTTP protcol $api->setHttpProtocol(HTTPS); // use a proxy server $api->setProxy("example.org", 8080, "login", "password");
SOAP Example 1: Retrieve a single product item
require_once 'client/ApiClient.php'; $client = ApiClient::factory(PROTOCOL_SOAP, VERSION_2009_07_01); $client->setConnectId("580599047DF8F5311043"); $soapObj = $client->getProduct('76485b5f7021f7bc03b853fbf5debb53'); var_dump($soapObj);
SOAP Example 2: Searching for products
require_once 'client/ApiClient.php'; $client = ApiClient::factory(PROTOCOL_SOAP, VERSION_2009_07_01); $client->setConnectId("580599047DF8F5311043"); $soapObj = $client->searchProducts('iphone'); var_dump($soapObj);
RESTful Example 1: Retriving adspaces and transforming XML result to array
require_once 'client/ApiClient.php'; $client = ApiClient::factory(PROTOCOL_XML, VERSION_2009_07_01); $connectId = '__your_connect_id__'; $publicKey = '__your_public_key__'; $secretKey = '__your_secrect_key__'; $client->setConnectId($connectId); $client->setSecretKey($secretKey); $client->setPublicKey($publicKey); $xml = $client->getAdspaces(); // optional unserialization step $array = $api->unserialize($xml); var_dump($array);
RESTful Example 2: Retriving programs and transforming JSON result to array
require_once 'client/ApiClient.php'; $client = ApiClient::factory(PROTOCOL_XML, VERSION_2009_07_01); $connectId = '__your_connect_id__'; $publicKey = '__your_public_key__'; $secretKey = '__your_secrect_key__'; $client->setConnectId($connectId); $client->setSecretKey($secretKey); $client->setPublicKey($publicKey); $json= $client->getAdspaces(); // optional unserialization step $array = $json->unserialize($json); var_dump($array);