1Net::Twitter::Role::AutUosCeurrsCoorn(t3r)ibuted Perl DoNceutm:e:nTtwaittitoenr::Role::AutoCursor(3)
2
3
4

NAME

6       Net::Twitter::Role::AutoCursor - Help transition to cursor based access
7       to friends_ids and followers_ids methods
8

VERSION

10       version 4.01043
11

SYNOPSIS

13         use Net::Twitter;
14         my $nt = Net::Twitter->new(
15             traits => [qw/AutoCursor API::RESTv1_1 RetryOnError OAuth/],
16             # additional ags...
17         );
18
19         # Get friends_ids or followers_ids without worrying about cursors
20         my $ids = $nt->followers_ids;
21
22         my $nt = Net::Twitter->new(
23             traits => [
24                 qw/API::RESTv1_1 RetryOnError OAuth/
25                 AutoCursor => { max_calls => 32 },
26                 AutoCursor => {
27                     max_calls      => 4,
28                     force_cursor   => 1,
29                     array_accessor => 'users',
30                     methods        => [qw/friends followers/],
31                 },
32             ],
33             # additional args
34         );
35
36         # works with any Twitter call that takes a cursor parameter
37         my $friends = $nt->friends;
38

DESCRIPTION

40       On 25-Mar-2011, Twitter announced a change to "friends_ids" and
41       "followers_ids" API methods:
42
43         [Soon] followers/ids and friends/ids is being updated to set the cursor to -1
44         if it isn't supplied during the request. This changes the default response
45         format
46
47       This will break a lot of existing code.  The "AutoCursor" trait was
48       created to help users transition to cursor based access for these
49       methods.
50
51       With default parameters, the "AutoCursor" trait attempts a non-cursored
52       call for "friends_ids" and "followers_ids".  If it detects a cursored
53       response from Twitter, it continues to call the underlying Twitter API
54       method, with the next cursor, until it has received all results or 16
55       calls have been made (yielding 80,000 results).  It returns an ARRAY
56       reference to the combined results.
57
58       If the "cursor" parameter is passed to "friends_ids" or
59       "followers_ids", "Net::Twitter" assumes the user is handling cursoring
60       and does not modify behavior or results.
61
62       The "AutoCursor" trait is parameterized, allowing it to work with any
63       Twitter API method that expects cursors, returning combined results for
64       up to the maximum number of calls specified.
65
66       "AutoCursor" can be applied multiple times to handle different sets of
67       API methods.
68

PARAMETERS

70       max_calls
71           An integer specifying the maximum number of API calls to make.
72           Default is 16.
73
74           "max_calls" can be overridden on a per-call basis by passing a
75           "max_calls" argument to the API method.
76
77       force_cursor
78           If true, when the caller does not provide a "cursor" parameter,
79           "AutoCursor" will use up to "max_calls" cursored calls rather than
80           attempting an initial non-cursored call.  Default is 0.
81
82       array_accessor
83           The name of the HASH key used to access the ARRAY ref of results in
84           the data structure returned by Twitter.  Default is "ids".
85
86       methods
87           A reference to an ARRAY containing the names of Twitter API methods
88           to which "AutoCursor" will be applied.
89

METHOD CALLS

91       Synthetic parameter "-max_calls" can be passed for individual method
92       calls to override the default:
93
94         $r = $nt->followers_ids({ -max_calls => 200 }); # get up to 1 million ids
95
96       Synthetic parameter "-force_cursor" can be passed to override the
97       "force_cursor" default.
98

AUTHOR

100       Marc Mims <marc@questright.com>
101
103       Copyright (c) 2016 Marc Mims
104

LICENSE

106       This library is free software and may be distributed under the same
107       terms as perl itself.
108
109
110
111perl v5.34.0                      2021-07-22 Net::Twitter::Role::AutoCursor(3)
Impressum