Skip to content

Instantly share code, notes, and snippets.

@lopnor
Created January 2, 2010 23:08
Show Gist options
  • Select an option

  • Save lopnor/267715 to your computer and use it in GitHub Desktop.

Select an option

Save lopnor/267715 to your computer and use it in GitHub Desktop.
#!perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
use XML::Atom::Feed;
my $ua = LWP::UserAgent->new;
my $email = 'fill.me@gmail.com';
my $password = 'fillme';
my $res = $ua->request(
POST 'https://www.google.com/accounts/ClientLogin',
[
Email => $email,
Passwd => $password,
service => 'writely',
source => 'test',
accountType => 'HOSTED_OR_GOOGLE',
]
);
my $auth = { split(/[\n=]/, $res->content) }->{Auth} or die "can't get Auth";
my $feed_res = $ua->request(
GET 'https://docs.google.com/feeds/default/private/full/-/document',
Authorization => "GoogleLogin auth=\"$auth\"",
'GData-Version' => '3.0',
);
my $feed = XML::Atom::Feed->new(\($feed_res->content));
my $entry = [ $feed->entries ]->[0] or die "no docs here";
my $url = $entry->content->elem->getAttribute('src');
my $export_res = $ua->request(
GET $url,
Authorization => "GoogleLogin auth=\"$auth\"",
'GData-Version' => '3.0',
);
warn $export_res->as_string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment