E
ethandbrown
Hi Group--
Has anyone succeeded in interacting with google calendars via Perl?
Google provides client libraries for Java, but not Perl.
I'm working with the Net::Google::Calendar module and am able
to connect and obtain calendar entries, but am not successful at
creating a new entry using the sample code provided by the module.
I'm getting a "401 Token invalid" error, which would lead me to
believe the problem is in either the feed url or the user/password,
but I can't seem to find a problem in either.
Thanks for any help,
--Ethan
Test code:
===========================================================================
#!/usr/bin/perl
##
## Test for google calendar module using mostly sample module code.
##
use Net::Google::Calendar;
use DateTime;
use Data:umper;
use strict;
use warnings;
my $u = 'gmail_user; ## Set this appropriately
my $p = 'gmail_password'; ## Ditto
my $url ## Ditto Ditto
=
'http://www.google.com/calendar/feeds/your/feed/url/private-14292c8fa1bc2ae9619ff356c58ca445/full';
my $cal = Net::Google::Calendar->new( url => $url );
$cal->login($u, $p);
## This Works
for ($cal->get_events()) {
print $_->title."\n";
print $_->content->body."\n*****\n\n";
}
my $title = 'Fnord';
my $entry = Net::Google::Calendar::Entry->new();
$entry->title($title);
$entry->content("My content");
$entry->location('London, England');
$entry->transparency('transparent');
$entry->status('confirmed');
$entry->when(DateTime->now, DateTime->now() + DateTime:uration->new(
hours => 6 ) );
my $author = Net::Google::Calendar:erson->new();
$author->name('Foo Bar');
$author->email('(e-mail address removed)');
$entry->author($author);
## This Fails
print "Trying to add the entry...\n";
my $tmp = $cal->add_entry($entry);
die "Couldn't add event: $@\n" unless defined $tmp;
print "Added the entry...\n";
print "Events=".scalar($cal->get_events())."\n";
$tmp->content('Updated');
$cal->update_entry($tmp) || die "Couldn't update ".$tmp->id.": $@\n";
$cal->delete_entry($tmp) || die "Couldn't delete ".$tmp->id.": $@\n";
===========================================================================
Result:
===========================================================================
ethan@strider:~/proj/wtgig/google_calendar$ ./testcal_basic.pl
Pelicans at La Grange
Dress:
Gold Coats
Blue coats
*****
Trying to add the entry...
Couldn't add event: 401 Token invalid - <HTML>
<HEAD>
<TITLE>Token invalid</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
===========================================================================
Has anyone succeeded in interacting with google calendars via Perl?
Google provides client libraries for Java, but not Perl.
I'm working with the Net::Google::Calendar module and am able
to connect and obtain calendar entries, but am not successful at
creating a new entry using the sample code provided by the module.
I'm getting a "401 Token invalid" error, which would lead me to
believe the problem is in either the feed url or the user/password,
but I can't seem to find a problem in either.
Thanks for any help,
--Ethan
Test code:
===========================================================================
#!/usr/bin/perl
##
## Test for google calendar module using mostly sample module code.
##
use Net::Google::Calendar;
use DateTime;
use Data:umper;
use strict;
use warnings;
my $u = 'gmail_user; ## Set this appropriately
my $p = 'gmail_password'; ## Ditto
my $url ## Ditto Ditto
=
'http://www.google.com/calendar/feeds/your/feed/url/private-14292c8fa1bc2ae9619ff356c58ca445/full';
my $cal = Net::Google::Calendar->new( url => $url );
$cal->login($u, $p);
## This Works
for ($cal->get_events()) {
print $_->title."\n";
print $_->content->body."\n*****\n\n";
}
my $title = 'Fnord';
my $entry = Net::Google::Calendar::Entry->new();
$entry->title($title);
$entry->content("My content");
$entry->location('London, England');
$entry->transparency('transparent');
$entry->status('confirmed');
$entry->when(DateTime->now, DateTime->now() + DateTime:uration->new(
hours => 6 ) );
my $author = Net::Google::Calendar:erson->new();
$author->name('Foo Bar');
$author->email('(e-mail address removed)');
$entry->author($author);
## This Fails
print "Trying to add the entry...\n";
my $tmp = $cal->add_entry($entry);
die "Couldn't add event: $@\n" unless defined $tmp;
print "Added the entry...\n";
print "Events=".scalar($cal->get_events())."\n";
$tmp->content('Updated');
$cal->update_entry($tmp) || die "Couldn't update ".$tmp->id.": $@\n";
$cal->delete_entry($tmp) || die "Couldn't delete ".$tmp->id.": $@\n";
===========================================================================
Result:
===========================================================================
ethan@strider:~/proj/wtgig/google_calendar$ ./testcal_basic.pl
Pelicans at La Grange
Dress:
Gold Coats
Blue coats
*****
Trying to add the entry...
Couldn't add event: 401 Token invalid - <HTML>
<HEAD>
<TITLE>Token invalid</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Token invalid</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
===========================================================================