Google calendar interaction

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::Dumper;

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::Duration->new(
hours => 6 ) );


my $author = Net::Google::Calendar::person->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>
===========================================================================
 
M

Mark Clements

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,

The test code works for me.

Are you specifying a full (e-mail address removed) for the username?

Are you sure the url is still valid? Are you sure you've chosen your
personal one and not the shared one?

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top