It took me some googling to find out quite how to do this, so in case anyone else needs to do this in future, here is a sample script using perl to access Matterhorn's REST webservices with digest authentication.
I don't have comment or edit access to the MH Wiki, but perhaps someone could add a perl example to http://opencast.jira.com/wiki/display/MH/Remote+Services or in another suitable place. Regards Stephen ---- #! /usr/bin/perl use WWW::Mechanize; use JSON; # imports encode_json, decode_json, to_json and from_json. my $url = "http://some.domain/workflow/statistics.json"; my $digest_user = "matterhorn_system_account"; my $digest_password="PASSWORD"; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->credentials($digest_user, $digest_password); $mech->add_header( 'X-REQUESTED-AUTH' => 'Digest' ); $mech->get($url); my $response = $mech->response(); # Headers for my $key ( $response->header_field_names() ) { print $key, " : ", $response->header( $key ), "\n"; } print "\n"; # Body if ($response->is_success) { print $response->decoded_content; # or whatever } else { die $response->status_line; } print "\n\n"; my $json = new JSON; my $statistics = $json->allow_nonref->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($response->decoded_content); print "Running: " . $statistics->{statistics}->{running} . "\n"; print "Failed: " . $statistics->{statistics}->{failed} . "\n"; -- Stephen Marquard, Acting Director Centre for Educational Technology, University of Cape Town http://www.cet.uct.ac.za Email / IM (Jabber/XMPP): [email protected] Phone: +27-21-650-5037 Cell: +27-83-500-5290 ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the UCT ICT policies and e-mail disclaimer published on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) to whom it is addressed. If the e-mail has reached you in error, please notify the author. If you are not the intended recipient of the e-mail you may not use, disclose, copy, redirect or print the content. If this e-mail is not related to the business of UCT it is sent by the sender in the sender's individual capacity. ### _______________________________________________ Matterhorn mailing list [email protected] http://lists.opencastproject.org/mailman/listinfo/matterhorn To unsubscribe please email [email protected] _______________________________________________
