.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Twitter::Role::AutoCursor 3pm" .TH Net::Twitter::Role::AutoCursor 3pm "2022-06-16" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Twitter::Role::AutoCursor \- Help transition to cursor based access to friends_ids and followers_ids methods .SH "VERSION" .IX Header "VERSION" version 4.01043 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& use Net::Twitter; \& my $nt = Net::Twitter\->new( \& traits => [qw/AutoCursor API::RESTv1_1 RetryOnError OAuth/], \& # additional ags... \& ); \& \& # Get friends_ids or followers_ids without worrying about cursors \& my $ids = $nt\->followers_ids; \& \& my $nt = Net::Twitter\->new( \& traits => [ \& qw/API::RESTv1_1 RetryOnError OAuth/ \& AutoCursor => { max_calls => 32 }, \& AutoCursor => { \& max_calls => 4, \& force_cursor => 1, \& array_accessor => \*(Aqusers\*(Aq, \& methods => [qw/friends followers/], \& }, \& ], \& # additional args \& ); \& \& # works with any Twitter call that takes a cursor parameter \& my $friends = $nt\->friends; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" On 25\-Mar\-2011, Twitter announced a change to \f(CW\*(C`friends_ids\*(C'\fR and \&\f(CW\*(C`followers_ids\*(C'\fR \s-1API\s0 methods: .PP .Vb 3 \& [Soon] followers/ids and friends/ids is being updated to set the cursor to \-1 \& if it isn\*(Aqt supplied during the request. This changes the default response \& format .Ve .PP This will break a lot of existing code. The \f(CW\*(C`AutoCursor\*(C'\fR trait was created to help users transition to cursor based access for these methods. .PP With default parameters, the \f(CW\*(C`AutoCursor\*(C'\fR trait attempts a non-cursored call for \f(CW\*(C`friends_ids\*(C'\fR and \f(CW\*(C`followers_ids\*(C'\fR. If it detects a cursored response from Twitter, it continues to call the underlying Twitter \s-1API\s0 method, with the next cursor, until it has received all results or 16 calls have been made (yielding 80,000 results). It returns an \s-1ARRAY\s0 reference to the combined results. .PP If the \f(CW\*(C`cursor\*(C'\fR parameter is passed to \f(CW\*(C`friends_ids\*(C'\fR or \f(CW\*(C`followers_ids\*(C'\fR, \&\f(CW\*(C`Net::Twitter\*(C'\fR assumes the user is handling cursoring and does not modify behavior or results. .PP The \f(CW\*(C`AutoCursor\*(C'\fR trait is parameterized, allowing it to work with any Twitter \&\s-1API\s0 method that expects cursors, returning combined results for up to the maximum number of calls specified. .PP \&\f(CW\*(C`AutoCursor\*(C'\fR can be applied multiple times to handle different sets of \s-1API\s0 methods. .SH "PARAMETERS" .IX Header "PARAMETERS" .IP "max_calls" 4 .IX Item "max_calls" An integer specifying the maximum number of \s-1API\s0 calls to make. Default is 16. .Sp \&\f(CW\*(C`max_calls\*(C'\fR can be overridden on a per-call basis by passing a \f(CW\*(C`max_calls\*(C'\fR argument to the \s-1API\s0 method. .IP "force_cursor" 4 .IX Item "force_cursor" If true, when the caller does not provide a \f(CW\*(C`cursor\*(C'\fR parameter, \f(CW\*(C`AutoCursor\*(C'\fR will use up to \f(CW\*(C`max_calls\*(C'\fR cursored calls rather than attempting an initial non-cursored call. Default is 0. .IP "array_accessor" 4 .IX Item "array_accessor" The name of the \s-1HASH\s0 key used to access the \s-1ARRAY\s0 ref of results in the data structure returned by Twitter. Default is \f(CW\*(C`ids\*(C'\fR. .IP "methods" 4 .IX Item "methods" A reference to an \s-1ARRAY\s0 containing the names of Twitter \s-1API\s0 methods to which \&\f(CW\*(C`AutoCursor\*(C'\fR will be applied. .SH "METHOD CALLS" .IX Header "METHOD CALLS" Synthetic parameter \f(CW\*(C`\-max_calls\*(C'\fR can be passed for individual method calls to override the default: .PP .Vb 1 \& $r = $nt\->followers_ids({ \-max_calls => 200 }); # get up to 1 million ids .Ve .PP Synthetic parameter \f(CW\*(C`\-force_cursor\*(C'\fR can be passed to override the \&\f(CW\*(C`force_cursor\*(C'\fR default. .SH "AUTHOR" .IX Header "AUTHOR" Marc Mims .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2016 Marc Mims .SH "LICENSE" .IX Header "LICENSE" This library is free software and may be distributed under the same terms as perl itself.