If you have any question left, please drop a note with the discussion link of this page.
PHP Getting Started Example
From Wiki.zanox.com
This is a simple example showing how to access the zanox product search with PHP.
Contents |
Screenshot
Code
PHP
<?php if(isset($_REQUEST['search']) && $_REQUEST['search'] != '') { $search = urlencode($_REQUEST['search']); } else { $search = urlencode('Kuckucksuhr'); } $zanox_server = 'http://api.zanox.com'; $zanox_host = 'api.zanox.com'; $zanox_Request_Method = 'GET'; $zanox_application_id = utf8_encode('ZXWS '); $zanox_application_id .= utf8_encode('BE94C4947839E8AB4D67');//USE YOUR OWN! $zanox_shared_key = 'abcdefghijklmnopqrstuvwxyz';//USE YOUR OWN! $zanox_get_param_date = gmdate('D, d M Y H:i:s').' GMT'; // Mon, 09 Jun 2008 08:17:35 GMT $zanox_Resource_URL = '/products?q='.$search; $zanox_string2sign = utf8_encode($zanox_Request_Method.$zanox_Resource_URL.$zanox_get_param_date); $zanox_signature = base64_encode(hash_hmac( 'SHA1' , $zanox_string2sign , $zanox_shared_key, true)); $zanox_application_id_security = $zanox_application_id.':'.$zanox_signature; $zanox_Request_URL = $zanox_server.'/xml'.$zanox_Resource_URL; $header[] = "Date: " . $zanox_get_param_date; $header[] = "Authorization: " . $zanox_application_id_security; $cobj=curl_init($zanox_Request_URL); curl_setopt($cobj, CURLOPT_HTTPHEADER, $header); curl_setopt ($cobj, CURLOPT_GET, true); // only with GET-Request, else the opts for post etc. curl_setopt($cobj, CURLOPT_RETURNTRANSFER, true); $Result=curl_exec($cobj); curl_close($cobj); ?>
HTML
<html> <head> <title>Product search: zanox webservices example</title> </head> <body> <form action="#" method="get"> <input type="text" name="search" value="Searchstring" /> <input type="submit" /> <textarea cols="10" rows="30"><?php echo $Result ?></textarea> </form> </body> </html>
