[Patches] [PATCH] Bug 7213: simple /svc/ HTTP example

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Fri Nov 11 11:20:02 NZDT 2011


From: Dobrica Pavlinusic <dpavlin at rot13.org>
Date: Thu, 10 Nov 2011 21:39:55 +0100
Subject: [PATCH] Bug 7213: simple /svc/ HTTP example

Simple command-line client which can authorize itself to Koha,
get MARC XML record based on biblio number and update record
---
 misc/migration_tools/koha-svc.pl |   43 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100755 misc/migration_tools/koha-svc.pl

diff --git a/misc/migration_tools/koha-svc.pl b/misc/migration_tools/koha-svc.pl
new file mode 100755
index 0000000..2570250
--- /dev/null
+++ b/misc/migration_tools/koha-svc.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use LWP::UserAgent;
+use File::Slurp;
+
+my $url = 'http://srvgit.koha-dev.rot13.org:8080/cgi-bin/koha/svc';
+
+my $biblionumber = 252283;
+
+my $file = "bib-$biblionumber.marcxml";
+
+my $user = 'svcuser';
+my $password = 'svcpasswd';
+my $debug = 1;
+
+my $ua = LWP::UserAgent->new();
+$ua->cookie_jar({});
+my $resp = $ua->post( "$url/authentication", {userid =>$user, password => $password} );
+die $resp->status_line unless $resp->is_success;
+print $resp->decoded_content;
+
+if ( ! -e $file ) {
+
+	$resp = $ua->get( "$url/bib/$biblionumber", userid =>$user, password => $password );
+	die $resp->status_line unless $resp->is_success;
+	write_file $file, $resp->decoded_content;
+	print "saved $file ", -s $file, " bytes\n";
+	print $resp->decoded_content;
+
+}
+
+print "update $biblionumber from $file\n";
+$resp = $ua->post( "$url/bib/$biblionumber", { #userid =>$user, password => $password,
+	POSTDATA => scalar read_file($file),
+} );
+die $resp->status_line unless $resp->is_success;
+
+print $resp->decoded_content;
+
+
-- 
1.7.2.5


More information about the Patches mailing list