phpbar.de logo

Mailinglisten-Archive

[php] [Fwd: [PHP Classes] Added a new class: Amazon API Access with PHP and XML]

[php] [Fwd: [PHP Classes] Added a new class: Amazon API Access with PHP and XML]

Andreas Kraftl php_(at)_phpcenter.de
19 Jul 2002 09:31:34 +0200


Für das Amazonthema :-)
--
Kraftl
EDV - Dienstleistungen             Tel: +43(0)676/3533220
Kundmanngasse 5/17              e-mail: Andreas.Kraftl_(at)_kraftl.at
1030 Wien                     Homepage: http://www.kraftl.at
Return-Path: <root_(at)_mail.linux-solutions.at>
Received: from mail.linux-solutions.at ([212.17.82.34]) by
  viefep15-int.chello.at (InterMail vM.5.01.03.06
  201-253-122-118-106-20010523) with ESMTP id
  <20020718231229.DPBS1259.viefep15-int.chello.at_(at)_mail.linux-solutions.a
  t> for <Andreas.Kraftl_(at)_chello.at>; Fri, 19 Jul 2002 01:12:29 +0200
Received: (from root_(at)_localhost) by mail.linux-solutions.at
  (8.11.6/linuxconf) id g6INCTX23636 for andi_(at)_linux-solutions.at; Fri,
  19 Jul 2002 01:12:29 +0200
Received: from linux.pt (linux.pt [194.65.79.153]) by
  mail.linux-solutions.at (8.11.6/linuxconf) with SMTP id g6INCRe23631
  for <Andreas.Kraftl_(at)_linux-city.at>; Fri, 19 Jul 2002 01:12:28 +0200
Received: (qmail 14089 invoked by uid 1005); 18 Jul 2002 22:38:52 -0000
Message-ID: <20020718223851.14087.qmail_(at)_linux.pt>
To: PHP Classes <void_(at)_phpclasses.org>
Subject: [PHP Classes] Added a new class: Amazon API Access with PHP and
  XML
Date: 18 Jul 2002 22:37:50 -0000
From: PHP Classes <subscriber-help_(at)_phpclasses.org>
Precedence: bulk
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,

If you do not want to receive more alert messages like this, see the
instructions at the bottom of this message.
---------------------------------------------------------------------------


A new class was added to "PHP Classes" repository.

Name: Amazon API Access with PHP and XML

Author: Uioreanu Calin <uioreanu_(at)_hotmail.com>

Description:
Now everybody heard of Amazon.com. What not everybody knows that Amazon
released an API to access its huge catalogs. What this basically means is
that each developer can access the information from Amazon following some
simple protocols and every site owner can enhance his own website with
content and features from Amazon.

The Amazon API comes as a simple Webservice. Here are the first Web
services that they have exposed:
- Product Display : The ability to search for and retrieve product
information from the Amazon.com catalog.
- Shopping Cart : The ability to add Amazon.com products to shopping carts,
wish lists, and registries from third party locations.

No matter of your intentions, you will first need to register and obtain a
valid developer token. You can get your token here at this address:
http://www.amazon.com/webservices

The current listed implementation of Amazon webservices uses Keyword
searches. It has basically the same results as searching the books catalog
online. As any developer/webmaster can see in the "Amazon.com Web Services
Developers Kit v 1.0" document, a lot of other Amazon features are exposed.
This would imply extending the base structure I present here.

There are multiple approaches from a developer's point of view. The
simplest one deals with SOAP and web services classes already implemented
in PHP. You could also extend the PEAR's XMLParser object to parse Amazon
results. The reason I did not choose these directions is because they
require additional extensions installed with PHP. What I currently use is
the XML parsing package that comes embedded in PHP, so it is slightly more
general.

What basically happens in this implementation is that the search word
entered by the used is embedded into a XML url that is then retrieved from
Amazon.com. Then PHP builds a nice display for the information received.

I should let the code talk for itself. Here is the main controller, with a
small search form for Amazon:

http://www.php9.com/php/source/amazon.phps

As you see, the actual code is very small. Then here is the class used in
the controller to parse the XML returned by Amazon.

http://www.php9.com/php/source/amazon_class.phps

Then the configuration file. I need to remember you that you need to change
the DEVELOPER_TOKEN constant with the one you will obtain from Amazon. The
current license key belongs to me.

http://www.php9.com/php/source/amazon_config.phps

And here is the layout template used to build the output from the XML
document retrieved from Amazon. It is parsed every time a book record is
retrieved, so the output rendering is the fastest possible.

http://www.php9.com/php/source/amazon_layout.phps

Here you have the full package zipped.

http://www.php9.com/php/source/amazon.zip

And of course a demo: http://www.php9.com/amazon.php

Feel free to use it and improve. I am open to suggestions.

URL: http://www.phpclasses.org/browse.html/package/642.html

---------------------------------------------------------------------------
If you do not want to receive any more alert messages like this one or want
to receive a weekly or daily digest newsletter instead, go to the User
Options page of the site "PHP Classes" located at
http://www.phpclasses.org/user_options.html and change the respective
e-mail notification options.


php::bar PHP Wiki   -   Listenarchive