Rev app to pull data from Amazon

RGould8 at aol.com RGould8 at aol.com
Tue Aug 8 11:50:51 EDT 2006


Dan,

     Well, I have followed the instructions and have put the PERL script on 
my web-server like the Amazon API instructions say:


#!/usr/local/bin/perl -w

# This program shows how to use LWP::Simple to make an Amazon Web
# Services (AWS) REST request, and how to process the response with
# XML::XPath.

use strict;
use LWP::Simple qw($ua get);
use XML::XPath;

# Retrieve command line arguments and combine them with escaped space 
characters.
die "Usage: $0 <space-separated list of keywords>\n"
     unless @ARGV;
my $keywords = join "%20", @ARGV;

# Define parts of the REST request.
my $baseurl = "http://webservices.amazon.com/onca/xml";
my $service = "AWSECommerceService";
my $accesskey = "<mylicensekeycode>";
my $operation = "ItemSearch";
my $searchindex = "Books";
my $responsegroup = "Request,Small";
my $version = "2005-10-13";

# Assemble the REST request URL.
my $request =
     "$baseurl?" .
     "Service=$service&" .
     "AWSAccessKeyId=$accesskey&" .
     "Operation=$operation&" .
     "Keywords=$keywords&" .
     "SearchIndex=$searchindex&" .
     "ResponseGroup=$responsegroup&" .
     "Version=$version" ;

# Send the request using HTTP GET.
my $ua = new LWP::UserAgent;
$ua->timeout(30);
my $response = get($request);

# Process XML response with XPath.
my $xp = XML::XPath->new(xml => $response);

if ( $xp->find("//Error") )
{
     print "There was an error processing your request:\n", 
           "   Error code: ", $xp->findvalue("//Error/Code"), "\n",
           "   ", $xp->findvalue("//Error/Message"), "\n\n";
}
else
{
     for (my $i = 1; $i <= 10; $i++)
     {
         if ( ! $xp->find("/ItemSearchResponse/Items/Item[$i]") )
         {
             last;
         }
         my @authors;
         for (my $j = 1;
              $j <= $xp->
findvalue("count(/ItemSearchResponse/Items/Item[$i]/ItemAttributes/Author)");
              $j++)
         {
             push @authors, $xp->
findvalue("/ItemSearchResponse/Items/Item[$i]/ItemAttributes/Author[$j]");
         }
         
         print "Title: ", $xp->
findvalue("/ItemSearchResponse/Items/Item[$i]/ItemAttributes/Title"), "\n",
         "Author: ", join(", ", @authors), "\n",
         "ASIN: ", $xp->findvalue("/ItemSearchResponse/Items/Item[$i]/ASIN"), 
"\n\n";
     }
}




The part I'm having trouble with is how to get Revolution to talk to this 
PERL script and pass data to it.   I try things like:

put URL "www.mywebserver.com/itemsearch_rest.pl?Elvis" into databack


but I get this error back:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable 
to complete your request.
Please contact the server administrator, webmaster at librarytools.com and 
inform them of the time the error occurred, and anything you might have done that 
may have caused the error.
More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an 
ErrorDocument to handle the request.


I'm wondering if perhaps the ?Elvis part isn't really what the PERL script is 
expecting for a parameter.   Do you know if there's another way to pass 
parameters to that PERL script?   My ISP doesn't give me SSH Telnet capability, so 
I need to pass/receive data via URLs.




In a message dated 8/3/06 6:13:51 PM, revolutionary.dan at gmail.com writes:


> I've done a bit of work in this area but nothing ambitious. But I can 
> answer
> your other question below. Yes, you do need a developer account.
> 
> On 8/3/06, RGould8 at aol.com <RGould8 at aol.com> wrote:
> >
> > Do I need to get one
> > of the Amazon security-service certificates in order to do this?
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
> 
> 
> 
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Dan Shafer, Information Product Consultant and Author
> http://www.shafermedia.com
> Get my book, "Revolution: Software at the Speed of Thought"
> >From http://www.shafermediastore.com/tech_main.html
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 




More information about the use-livecode mailing list