source: gs3-extensions/hathitrust-downloadfrom/trunk/signed-htc-get-data-api.pl@ 26436

Last change on this file since 26436 was 26436, checked in by davidb, 11 years ago

Initial cut at code for exporting content out of the Hathitrust, suitable for ingest by Greenstone

File size: 1.3 KB
Line 
1#!/usr/bin/perl -w
2
3use strict;
4use warnings;
5
6use CGI;
7use OAuth::Lite::Consumer;
8use OAuth::Lite::AuthMethod;
9
10#my $access_key = 'PUBLIC_OAUTH_CONSUMER_KEY';
11#my $secret_key = 'PUBLIC_OAUTH_CONSUMER_SECRET';
12
13my $access_key = '7e6ee38bae'; # PUBLIC_OAUTH_CONSUMER_KEY
14my $secret_key = 'e0429c0394385486249b4a230702'; # PUBLIC_OAUTH_CONSUMER_SECRET
15
16#my $request_url = 'http://babel.hathitrust.org/cgi/htd/dapiserver';
17#my $request_url = "http://babel.hathitrust.org/cgi/htd/meta/mdp.39015019203879";
18my $request_url = "http://babel.hathitrust.org/cgi/htd/pagemeta/mdp.39015000000128/12";
19
20
21my $consumer = OAuth::Lite::Consumer->new( 'consumer_key' => $access_key,
22 'consumer_secret' => $secret_key,
23 'auth_method' => OAuth::Lite::AuthMethod::URL_QUERY );
24
25my $response = $consumer->request( 'method' => 'GET',
26 'url' => $request_url,
27# 'params' => { 'hello' => 'world' }
28);
29
30print CGI::header();
31
32print "<p><b>[CLIENT] sent this URL to server:</b><br/>";
33print $consumer->oauth_request->uri;
34
35print "<p><b>[CLIENT] received this HTTP response from server:</b><br/>";
36print $response->status_line;
37
38if ($response->is_success) {
39 print "<br/><b>[CLIENT] received this content response from server:</b><blockquote>" .
40 $response->content . "</blockquote>";
41}
42
43print STDERR "*****\n ", $consumer->oauth_request->uri, "\n";
44
45
46exit 0;
47
48
Note: See TracBrowser for help on using the repository browser.