Subject: | Complete Net::Twitter's implementation of replies() |
The current implementation of replies() only allows passing the page to
get. Twitter supports additional parameters (since, since_id).
The attached patch adds support for a hashref argument, but maintains
backwards compatibility with a scalar (assuming it to be the page number).
This is already used in twirssi (http://irc.peeron.com/~zigdon/twirssi/).
Thanks for the module!
Dan
Subject: | net-twitter.patch |
Only in Net-Twitter-1.17-patch: blib
diff -ru Net-Twitter-1.17/lib/Net/Twitter.pm Net-Twitter-1.17-patch/lib/Net/Twitter.pm
--- Net-Twitter-1.17/lib/Net/Twitter.pm 2008-08-12 16:54:20.000000000 -0700
+++ Net-Twitter-1.17-patch/lib/Net/Twitter.pm 2008-12-11 11:04:48.000000000 -0800
@@ -205,10 +205,13 @@
}
sub replies {
- my ( $self, $page ) = @_;
+ my ( $self, $args ) = @_;
+ $args = { page => $args } unless ref $args;
my $url = $self->{apiurl} . "/statuses/replies.json";
- $url .= ($page) ? '?page=' . $page : "";
+ $url .= ($args->{page}) ? '?page=' . $args->{page} : "";
+ $url .= ($args->{since}) ? '?since=' . $args->{since} : "";
+ $url .= ($args->{since_id}) ? '?since_id=' . $args->{since_id} : "";
my $req = $self->{ua}->get($url);
$self->{response_code} = $req->code;
@@ -856,15 +859,35 @@
C<following_timeline()> is DEPRECATED, see note below.
-=item C<replies([$page])>
+=item C<replies(...)>
Returns the 20 most recent replies (status updates prefixed with @username
posted by users who are friends with the user being replied to) to the
authenticating user.
-Accepts an optional argument for page to retrieve, which will the 20 next
-most recent statuses from the authenticating user and that user's friends,
-eg "page=3"
+Accepts an option argument hashref:
+
+=over
+
+=item C<page>
+
+Page to retrieve, which will the 20 next most recent statuses from the
+authenticating user and that user's friends, eg "page=3"
+
+=item C<since>
+
+Narrows the returned results to just those statuses created after the
+specified HTTP-formatted date.
+
+=item C<since_id>
+
+Narrows the returned results to just those statuses created after the
+specified ID.
+
+=back
+
+Note that for backwards compatibility, if the argument passed is not a hashref,
+it's assumed to be the page number.
=back
Only in Net-Twitter-1.17-patch/lib/Net: .Twitter.pm.swp
Only in Net-Twitter-1.17-patch: Makefile
Only in Net-Twitter-1.17-patch: pm_to_blib
diff -ru Net-Twitter-1.17/README Net-Twitter-1.17-patch/README
--- Net-Twitter-1.17/README 2008-08-12 16:54:22.000000000 -0700
+++ Net-Twitter-1.17-patch/README 2008-12-11 11:05:26.000000000 -0800
@@ -2,7 +2,7 @@
Net::Twitter - Perl interface to twitter.com
VERSION
- This document describes Net::Twitter version 1.16
+ This document describes Net::Twitter version 1.17
SYNOPSIS
#!/usr/bin/perl
@@ -200,14 +200,28 @@
"following_timeline()" is DEPRECATED, see note below.
- "replies([$page])"
+ "replies(...)"
Returns the 20 most recent replies (status updates prefixed with
@username posted by users who are friends with the user being
replied to) to the authenticating user.
- Accepts an optional argument for page to retrieve, which will the 20
- next most recent statuses from the authenticating user and that
- user's friends, eg "page=3"
+ Accepts an option argument hashref:
+
+ "page"
+ Page to retrieve, which will the 20 next most recent statuses
+ from the authenticating user and that user's friends, eg
+ "page=3"
+
+ "since"
+ Narrows the returned results to just those statuses created
+ after the specified HTTP-formatted date.
+
+ "since_id"
+ Narrows the returned results to just those statuses created
+ after the specified ID.
+
+ Note that for backwards compatibility, if the argument passed is not
+ a hashref, it's assumed to be the page number.
USER METHODS
"following()" DEPRECATED