Page 1 of 1

Help with Xtra

Posted: Thu Jan 27, 2005 2:37 am
by bizark
I'm trying to make a script that accesses google's atom feed and parses it. However for some reason all my code returns is a empty set of quotes. Below is the code any advice is appreciated.

Code: Select all

#!/usr/bin/perl

# Modules to use
use LWP::Simple;
use XML::RSS;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;

my $content;

$gmail_user = USERNAME;
$gmail_password = PASSWORD;

# Accessing Atom feed
$req = HTTP::Request->new(GET => 'https://gmail.google.com/gmail/feed/atom');
$req->header('Accept' => 'text/html');
$req->authorization_basic($gmail_user, $gmail_password);
$res = $ua->request($req);

# Printing content
my $rss = new XML::RSS;
 $content = $res->content;
    die "Could not retrieve" unless $content;
    # parse the RSS content
    $rss->parse($content);
# print the HTML channel
&print_html($rss);

# SUBROUTINES
sub print_html {
 my $rss = shift;
      # print the channel items
   foreach my $item (@{$rss->{'items'}}) {
	next unless defined($item->{'title'}) && defined($item->{'link'});
	print "<li><a href=\"$item->{'link'}\">$item->{'title'}</a><BR>\n";
    }
    }


Posted: Thu Jan 27, 2005 4:32 am
by zaudragon
Just a question: since Adium only supports AppleScript Xtras as script Xtras, how are you going to submit this?

Posted: Thu Jan 27, 2005 11:57 am
by bizark

Code: Select all

do shell script "perl script.pl"
return result

Posted: Fri Jan 28, 2005 12:34 am
by zaudragon
cool, I was just unsure :D