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

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Fri Nov 11 09:50:03 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

---
 misc/migration_tools/koha-svc.pl |   47 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 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..6ba9ae0
--- /dev/null
+++ b/misc/migration_tools/koha-svc.pl
@@ -0,0 +1,47 @@
+#!/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;
+
+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;
+
+$resp = $ua->post( "$url/bib/$biblionumber", {userid =>$user, password => $password} );
+die $resp->status_line unless $resp->is_success;
+
+print "Authentication successful\n";
+
+my $resp = $ua->post( "$url/bib/$biblionumber", {userid =>$user, password => $password,
+	POSTDATA => scalar read_file($file),
+} );
+
+print $resp->status_line;
+
+die $resp->status_line unless $resp->is_success;
+
-- 
1.7.2.5




More information about the Patches mailing list