I'm a newbie to programming with Google APIs and can't
figure out why the following doesn't work and wondered
if anyone here could help. (I get a 400 Bad Request error.)
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
# Create a request
my $req = HTTP::Request->new(POST =>
'http://www.google.com/calendar/feeds/default/private/full');
$req->header(Authorization => "GoogleLogin auth=xxxxxx");
$req->content(<<EOT);
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/g/2005#event'></category>
<title type='text'>Tennis with Beth</title>
<content type='text'>Meet for a quick lesson.</content>
<author>
<name>Gk</name>
<email>xxxx_email_xxxx@xxxxxxxxx</email>
</author>
<gd:transparency
value='http://schemas.google.com/g/2005#event.opaque'>
</gd:transparency>
<gd:eventStatus
value='http://schemas.google.com/g/2005#event.confirmed'>
</gd:eventStatus>
<gd:where valueString='Rolling Lawn Courts'></gd:where>
<gd:when startTime='2006-09-10T08:00:00.000Z'
endTime='2006-09-10T10:00:00.000Z'></gd:when>
</entry>
EOT
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
print $res->content;
}
else {
print $res->status_line, "\n";
}
|