Zanox PHP API Client
From Wiki.zanox.com
In order to use the zanox Web Services, you will need to use an special authentication scheme with an applicationId and a sharedKey. To accelerate your development efforts we provide a PHP API Client that you can download and use to simplify monetization of your application. Please see below for how to install and use this official zanox PHP API client.
Contents |
[edit] Download
Download our latest PHP API client library (ZIP format).
[edit] Requirements
These are the minimum requirements:
- PHP 5 >= 5.2.0
- PEAR (for RESTful XML and JSON API)
[edit] Installation
Upload and install it on your server. In order to use the RESTful (XML/JSON) PHP API client you need to have a working PEAR environment set up. Using the SOAP API just requires PHP5 to be installed.
PEAR Installation for RESTful API
In order to use the XML and JSON API interface you need these two PEAR libraries to be installed at your server. XML_Serializer is required to transform the XML data into an array structure and HTTP_Request for the HTTP API requests.
$ pear install -f XML_Serializer $ pear install HTTP_Request
[edit] Usage
Copy code examples and edit the code to use your applicationId and sharedKey (shared secret). The detailed documentation of the API client can be found inside of the source code and conforms to the PHPDoc standard.
Step 1: Include API client and get interface instance
// include zanox API client library require_once 'zanox-api.class.php'; // create a RESTful JSON interface instance $zx = ZanoxAPI::factory('json', '2008-05-21'); // or create a RESTful XML interface instance $zx = ZanoxAPI::factory('xml', '2008-05-21'); // or create a SOAP interface instance without version $zx = ZanoxAPI::factory('soap');
Step 2: Set up authentication credentials
// set the authentication credentials $application_id = 'your_application_id'; $shared_key = 'your_shared_key'; $zx->setMessageCredentials($application_id, $shared_key);
Example 1: Retrieve a single product item or search for products
// Get a single product item $result = $zx->getProduct('76485b5f7021f7bc03b853fbf5debb53'); // Search products $result = $zx->searchProducts('iphone');
Example 2: Create a new adspace
// Create new adspace $adspace_item = array( 'name' => 'My new Adspace', 'url' => 'http://www.example.com', 'contact' => 'contact@example.com', 'description' => 'This website contains ...', 'visitors' => 100000, 'impressions' => 5000000, 'type' => 'website', 'scope' => 'business', 'regions' => array( 'region' => 'de', 'region' => 'en' ), 'categories' => array( 'category' => 11, 'category' => 12 ) ); $result = $zx->createAdspace($adspace_item);
Example 3: Update an adspace
// Update adspace item $adspace_item = array( 'contact' => 'you@example.com', 'scope' => 'private', 'type' => 'website' ); $result = $zx->updateAdspace('your_adspace_id', $adspace_item);
Example 4: Get programs and search programs
// Get all advertiser programs $result = $zx->getPrograms(); // Search programs $result = $zx->searchPrograms('telecom');
Example 5: Retrieve your payments
// Get your payment history $result = $zx->getPayments();
Example 6: Retrieve your payments
// get your zanox profile $result = $zx->getProfile(); // Update your profile $profile_item = array( 'email' => 'bugs.bunny@servtag.com', 'company' => 'servtag', ); $result = $zx->updateProfile($profile_item);