[LON-CAPA-cvs] cvs: modules /studip testqueries.pl

www www@source.lon-capa.org
Sun, 05 Jun 2011 19:35:39 -0000


www		Sun Jun  5 19:35:39 2011 EDT

  Added files:                 
    /modules/studip	testqueries.pl 
  Log:
  Testing the queries against Stud.IP
  
  

Index: modules/studip/testqueries.pl
+++ modules/studip/testqueries.pl
use strict;
use LWP::UserAgent;

my $url='http://vm036.rz.uni-osnabrueck.de/studip/lc/xmlrpc.php';
my $pwd='lc-test';

sub send {
    my ($cmd,@args)=@_;
    my $commands='<methodCall><methodName>'.$cmd.'</methodName><params>';
    foreach my $param ($pwd,@args) {
        $commands.='<param><value><string>'.$param.'</string></value></param>';
    }
    $commands.='</params></methodCall>';
    my $ua=new LWP::UserAgent;
    $ua->timeout(4);
    my $headers = HTTP::Headers->new() ;
    my $request = new HTTP::Request('POST',$url.'?methodName='.$cmd,$headers);
    $request->content($commands);
    my $response=$ua->request($request);
    my %returned=();
    my $error='';
    if ($response->is_success()) {
        my $content = $response->content;
        print "\n$content\n";
    } else {
        $error = "ERROR: ".$response->status_line;
    }
    return ($error,%returned);
}

&send('get_seminar_groups','834499e2b8a2cd71637890e5de31cba3');