Having an array with dates and names I want to add events to a google calendar with the following subroutine:
use Net::Google::Calendar;
use Date::Manip;
use Date::Calc qw(Add_Delta_Days);
my $username #removed for stackoverflow
my $password #removed for stackoverflow
my $cal = Net::Google::Calendar->new;
my $from = new Date::Manip::Date;
my $to = new Date::Manip::Date;
my @f;
my @t;
my $year;
my $month;
my $day;
$cal->login($username, $password) or $MESSAGERED = "Google Calendar login failed.";
my $entry;
#[0] name
#[1] from
#[2] to
#[3] hid
for my $i (0 .. $#ALL_HOLIDAYS) {
$from->parse($ALL_HOLIDAYS[$i][1]);
$to->parse($ALL_HOLIDAYS[$i][2]);
@f = $from->value();
@t = $to->value();
# a day added in line with our "last day of absence"
($year, $month, $day) = Add_Delta_Days($t[0], $t[1], $t[2], 1);
$entry = Net::Google::Calendar::Entry->new() or die " 518 ++++++++++ ";
$entry->when(DateTime->new(year => $f[0], month => $f[1], day => $f[2]), DateTime->new(year => $year, month => $month, day => $day)) or die " 519 ++++++++++ ";
$entry->title($ALL_HOLIDAYS[$i][0]) or die " 520 ++++++++++ ";
$entry->content("Holiday") or die " 521 ++++++++++ ";
$entry->transparency('transparent') or die " 522++++++++++ ";
$entry->status('confirmed') or die " 523 ++++++++++ ";
if ($cal->add_entry($entry)) {
&mark_entry_as_googd($ALL_HOLIDAYS[$i][3]);
} else {
$MESSAGEORANGE = "Unable to submit entry for ".$ALL_HOLIDAYS[$i][0]
}
}
$MESSAGEGREEN = "Google Calendar populated";
print $MESSAGERED.$MESSAGEGREEN.$MESSAGEORANGE;
Thing is as soon as I take this script off and run it in my console (osx) it runs all right, the events are added to google calendar.
If it executes on the debian server the following error, the reason for me asking this question, is received:
No namespace matches prefix: xmlns at /usr/local/share/perl/5.10.1/XML/XPath/Node/Element.pm line 261.
CPAN reports the same thing on both machines, that both Net::Google::Calendar and its dependencies are installed. None of those dies work either, it’s always that same error. I realise this module is alpha but still, why the discrepancy?
My guess is the Google module is not setting the correct namespace for the entry in the xml response. Its falling back to the default namespace (nothing). Entries may look like < somename:tag > without setting the namespace to somename, the app cannot retrieve that data. The default is ‘xmls’, so the default namespace is looking for tags like < xmls:tag > and cannot find any. (The default namespace may be different on each installation – check the xmlib versions as well, I recall the default was changed to ‘xmlns’ recently to force namespace usage).
Without seeing the xml response, its hard to answer correctly. Is there a way you can capture or dump the response to a file. Once you see the header, you can see where the problem is. If the xml response is correct, then the module isnt setting the namespace, which would be bug on their end.
Example of namespaces with xmlns