Net::OAuth::Consumerを作ってみた
http://coderepos.org/share/browser/lang/perl/Net-OAuth-Consumer
使い方は↓こんな感じ。
#!/usr/bin/perl # index.cgi use strict; use warnings; use CGI; use Net::OAuth::Consumer; use Template; use DB_File; my $q = CGI->new; tie my %oauth_token, "DB_File", "oauth_token.db"; my $oauth = Net::OAuth::Consumer->new({ query => $q, consumer_key => 'your_consumer_key', consumer_secret => 'your_consumer_secret', request_token_url => 'http://lopnor.homeip.net/picshare/api/request_token.cgi', authorization_url => 'http://lopnor.homeip.net/picshare/api/authorize.cgi', access_token_url => 'http://lopnor.homeip.net/picshare/api/access_token.cgi', }); if (my $authorized_token = $q->param('oauth_token')) { my $secret = $oauth_token{$authorized_token}; my $res = $oauth->request({ request_token => $authorized_token, request_token_secret => $secret, request_url => 'http://lopnor.homeip.net/picshare/api/piclist.cgi', params => {}, }); print $q->header; print Template->new->process(\'<pre>[% res.content | html %]</pre>', {res => $res}); } elsif ($q->param('start')) { my $res = $oauth->get_request_token; $oauth_token{$res->oauth_token} = $res->oauth_token_secret; $oauth->authorize; } else { print $q->header; print <<END <html> <body> <form method="post" "./index.cgi"> <input type="submit" name="start" value="start"> </form> </body> </html> END } untie %oauth_token;
こんなもんでどうだろうか。→id:ZIGOROu先生に添削してもらった!どうもです!