onyourmark
asked on
how to use a package in Perl
Can anyone give me a clue about how to use this package in perl. I have not programmed in perl in about 8 years and I forget almost everything.
http://search.cpan.org/~miyagawa/AnyEvent-Twitter-Stream-0.16/lib/AnyEvent/Twitter/Stream.pm#SYNOPSIS
http://search.cpan.org/~miyagawa/AnyEvent-Twitter-Stream-0.16/lib/AnyEvent/Twitter/Stream.pm#SYNOPSIS
THANKS
http://search.cpan.org/~miyagawa/AnyEvent-Twitter-Stream-0.16/lib/AnyEvent/Twitter/Stream.pm#SYNOPSIS
http://search.cpan.org/~miyagawa/AnyEvent-Twitter-Stream-0.16/lib/AnyEvent/Twitter/Stream.pm#SYNOPSIS
THANKS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello. I tried the following code (the example). It says the ... on line 18 and on line 40 are producing errors. What do I do with those?
Also, where do I enter the username and password?
Thanks.
use AnyEvent::Twitter::Stream;
# receive updates from @following_ids
my $listener = AnyEvent::Twitter::Stream- >new(
username => $user,
password => $password,
method => "filter", # "firehose" for everything, "sample" for sample timeline
follow => join(",", @following_ids),
on_tweet => sub {
my $tweet = shift;
warn "$tweet->{user}{screen_nam e}: $tweet->{text}\n";
},
on_keepalive => sub {
warn "ping\n";
},
on_delete => sub {
my ($tweet_id, $user_id) = @_; # callback executed when twitter send a delete notification
...
},
timeout => 45,
);
# track keywords
my $guard = AnyEvent::Twitter::Stream- >new(
username => $user,
password => $password,
method => "filter",
track => "Perl,Test,Music",
on_tweet => sub { },
);
# to use OAuth authentication
my $listener = AnyEvent::Twitter::Stream- >new(
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
token => $token,
token_secret => $token_secret,
method => "filter",
track => "...",
on_tweet => sub { ... },
);
Also, where do I enter the username and password?
Thanks.
use AnyEvent::Twitter::Stream;
# receive updates from @following_ids
my $listener = AnyEvent::Twitter::Stream-
username => $user,
password => $password,
method => "filter", # "firehose" for everything, "sample" for sample timeline
follow => join(",", @following_ids),
on_tweet => sub {
my $tweet = shift;
warn "$tweet->{user}{screen_nam
},
on_keepalive => sub {
warn "ping\n";
},
on_delete => sub {
my ($tweet_id, $user_id) = @_; # callback executed when twitter send a delete notification
...
},
timeout => 45,
);
# track keywords
my $guard = AnyEvent::Twitter::Stream-
username => $user,
password => $password,
method => "filter",
track => "Perl,Test,Music",
on_tweet => sub { },
);
# to use OAuth authentication
my $listener = AnyEvent::Twitter::Stream-
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
token => $token,
token_secret => $token_secret,
method => "filter",
track => "...",
on_tweet => sub { ... },
);
the ... is meant to be filled in with your own code.
what do you want to do with the twitter stream?
what do you want to do with the twitter stream?
ASKER
just download it to csv files (continuously but the first step is just to download something). Thanks.
But do you want to follow someone (someones...) or track some keywords?
ASKER
no. I wanted to download all the tweets. do you know if this module can do that?
According to this article: http://www.businessinsider.com/twitter-stats-2010-4#twitters-users-are-doing-55-million-tweets-per-day-6 in Apr 2010, there was 55 millions tweets a day... are you really considering getting that many tweets.
I'm not even sure it's allowed to subscribe to all.
I'm not even sure it's allowed to subscribe to all.
ASKER
Hi. It is allowed to download 5% and that is what I was trying eventually to do but I don't know if this module assists with that or not.
ASKER