http://code.google.com/intl/ja/apis/documents/docs/2.0/developers_guide_protocol.html#UploadingMetadata を実際に送ってみると503が帰ってくる><。でもspreadsheet自体はできている。keyがとれなくて残念。 CSVを送りつけると201が帰ってくる。keyもとれてうれしい。 なんとなく↓こんな感じ。
my $login = Net::Google::AuthSub->new(
# service => 'wise',
service => 'writely',
);
my $auth = $login->login(
'username@gmail.com',
'password',
)->auth;
my $ua = LWP::UserAgent->new;
$ua->default_header('Authorization' => sprintf('GoogleLogin auth=%s', $auth));
$ua->default_header('GData-Version' => 2);
#503
{
my $atom = XML::Atom::Entry->new(Version => 1);
$atom->title('testtest');
$atom->set($atom->ns, 'category', '', {
scheme => 'http://schemas.google.com/g/2005#kind',
term => 'http://schemas.google.com/docs/2007#spreadsheet',
}
);
my $req = HTTP::Request->new(POST => 'http://docs.google.com/feeds/documents/private/full');
$req->header('Content-Type' => 'application/atom+xml');
$req->content($atom->as_xml);
warn $req->as_string;
my $res = $ua->request($req);
warn $res->as_string;
}
#201
{
my $csv = Text::CSV_XS->new(
{
binary => 1,
always_quote => 1,
}
);
$csv->combine('a','b','c');
my $req = HTTP::Request->new(
POST => 'http://docs.google.com/feeds/documents/private/full'
);
$req->header('Content-Type' => 'text/csv');
$req->header('Slug' => 'new name');
$req->content($csv->string);
my $res = $ua->request($req);
warn $res->as_string;
}
→ドキュメントのまんまのXMLをヒアドキュメントでやったら動いたな。 →XML::Atomで組み立てたのとドキュメントに書いてあるのとで動作が違うのか。
<?xml version='1.0' encoding='UTF-8'?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
<atom:category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/docs/2007#document" />
<atom:title>new document</atom:title>
</atom:entry>
と
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title>testtest</title>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#spreadsheet"></category>
</entry>
→なんとterm=”http://schemas.google.com/docs/2007#document” しか動いてなかった件><