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