summary refs log tree commit diff
path: root/lib/Net/Backtweet.pm
blob: 23e25c710db2113b195a7365fb489494be0ef794 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package Net::Backtweet;

# ABSTRACT: client for the backtweet API

use Moose;
use Net::HTTP::API;
extends 'Net::Backtype';

net_api_declare backtweet => (
    base_url    => 'http://api.backtype.com',
    format      => 'json',
    format_mode => 'append',
);

net_api_method tweets_by_url => (
    description =>
      'Retrieve tweets that link to a given URL, whether the links are shortened or unshortened.',
    path     => '/tweets/search/links',
    method   => 'GET',
    params   => [qw/q key itemsperpage start end/],
    required => [qw/q key/],
    expected => [qw/200/],
);

net_api_method stats_by_url => (
    description =>
      'Retrieve the number of tweets that link to a particular URL.',
    path     => '/tweetcount',
    method   => 'GET',
    params   => [qw/q batch key/],
    required => [qw/q key/],
    expected => [qw/200/],
);

net_api_method good_tweets_by_url => (
    description =>
      'Retrieve filtered tweets that link to a given URL with both shortened and unshortened links. This returns a subset of Tweets by URL.',
    path     => '/goodtweets',
    method   => 'GET',
    params   => [qw/q key/],
    required => [qw/q key/],
    expected => [qw/200/],
);

# back compatibility
sub backtweet_search {
    (shift)->tweets_by_url(@_);
}

1;

=head1 SYNOPSIS

  use Net::Backtweet;
  my $client = Net::Backtweet->new();
  my $res = $client->tweets_by_url(q => 'lumberjaph', key => 's3kr3t');

=head1 DESCRIPTION

Net::Backtype is a client for the backtweet API.

=head2 METHODS

=over 4

=item B<tweets_by_url>

Retrieve the number of tweets that link to a particular URL.

    my $tweets = $client->tweets_by_url(q => 'lumberjaph', key => 's3kr3t');

=over 2

=item B<q> query (required)

=item B<key> API key (required)

=item B<itemsperpage> number of items per page (optional)

=item B<start> date start (optional)

=item B<end> date end (optional)

=back

See L<http://www.backtype.com/developers/tweets-by-url>.

=item B<stats_by_url>

Retrieve the number of tweets that link to a particular URL.

    my $stats = $client->stats_by_url(q => 'lumberjaph', key => 's3kr3t');

=over 2

=item B<q> query (required)

=item B<key> API key (required)

=back

See L<http://www.backtype.com/developers/tweet-count>.

=item B<good_tweets_by_url>

Retrieve filtered tweets that link to a given URL with both shortened and unshortened links. This returns a subset of Tweets by URL.

    my $good = $client->good_tweets_by_url(q => 'lumberjaph', key => 's3kr3t');

=over 2

=item B<q> query (required)

=item B<key> API key (required)

=back

See L<http://www.backtype.com/developers/good-tweets>.

=back

See L<http://backtweets.com/api> for more information about the backtweets API.