#!/usr/bin/perl

use strict;
use warnings;

use LWP::UserAgent;
use HTTP::Request::Common;
use Net::OAuth;

my $ua = LWP::UserAgent->new;

my $req = Net::OAuth->request('consumer')->new(
	consumer_key => 'e10b51ebc827ce748296b35a',
	consumer_secret => 'a383f88072d78d9cfaeafe25',
	request_url => 'http://gdd-2010-quiz-japan.appspot.com/oauth/e10b51ebc827ce748296b35a',
	request_method => 'POST',
	signature_method => 'HMAC-SHA1',
	timestamp => time,
	nonce => 'actually_this_should_be_nonce',
	extra_params => {
		hello=>'world'
	}
);

$req->sign;

my $httpreq =
	POST $req->normalized_request_url,
		[ hello=>'world' ],
		'Authorization' => $req->to_authorization_header('devquiz');

my $res = $ua->request($httpreq);

if ($res->is_success) {
  print $res->decoded_content;
} else {
  print $res->decoded_content;
  die $res->status_line;
}
