Archive of UserLand's first discussion group, started October 5, 1998.

Re: Search Engine XML-RPC Interface

Author:Stephen Judd
Posted:1/27/1999; 6:41:43 PM
Topic:Search Engine XML-RPC Interface
Msg #:2541 (In response to 2454)
Prev/Next:2540 / 2542

I've hacked up a very quick and dirty one that runs as a CGI under Apache. So quick and so dirty that it pattern matches instead of parsing the XML.

I've set up an alias for "/RPC2" so that all requests get routed to a cgi. I believe this should work.

(I want this happening inside Apache, for various reasons).

I only have the trial version of Frontier (we're ordering 5.1 though!) - would someone mind trying to talk to asterix.cc.waikato.ac.nz:80 and tell me what happens?

Stephen

PS: source.

#!/usr/bin/perl

use MIME::Base64; use DBI;

my $length = $ENV{CONTENT_LENGTH}; my $buf; my $raw = $buf;

read STDIN, $buf, $length;

my @values;

while ($buf =~/(.*?)/igs) { push @values, $1; }

error("Not enough parameters!") if (scalar @values < 5); error("Too many parameters!") if (scalar @values > 5);

my $dbh = DBI->connect("xxx", "xxx", "xxx");

$values[2] = $dbh->quote(escapequotes(decode_base64($values[2]))); print STDERR $values[2] . "\n"; my $sql = "insert into engine values(\"$values[0]", "$values[1]", "$values[2]", "$values[3]", "$values[4]")"; my $sth = $dbh->prepare($sql); $sth->execute or error("Could not execute SQL: " . $sth->errstr);

print "Content-type: text/xml\n\n"; print < true $sql END

sub error { my $error = shift; print STDERR $sql; print "Content-type: text/xml\n\n"; print < faultCode 4 faultString $error. END exit; }

sub escapequotes { my $string=shift; $string=~s/"/""/g; $string=~s/r/\n/g; return $string; }




There are responses to this message:


This page was archived on 6/13/2001; 4:47:38 PM.

© Copyright 1998-2001 UserLand Software, Inc.