Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:05:55+00:00 2026-06-01T17:05:55+00:00

I’m trying to use the AnyEvent::Twitter::Stream module and I want to reference a file

  • 0

I’m trying to use the AnyEvent::Twitter::Stream module and I want to reference a file that lists the Twitter uids I want to follow. I can put the uids in the code itself and it works as follows:

my $done = AnyEvent->condvar;
       my $nt_filter = AnyEvent::Twitter::Stream->new(
             username => $cf{account},
             password => $cf{password},
           method => 'filter',
           follow => '15855509,14760150,18598536',
            on_tweet => sub {
                 #some code.....
            },
            on_error => sub {
                my $error = shift;
                debug "ERROR: $error";
            },
            timeout => 45,
        );
       $done->recv;

But when I try to do the same using a file as such:

my $done = AnyEvent->condvar;
       my $nt_filter = AnyEvent::Twitter::Stream->new(
           open UID_FILE, "/tmp/uids" or die $!;

           my @uid_line = <UID_FILE>;

             username => $cf{account},
             password => $cf{password},
           method => 'filter',
           follow => @uid_file,
            on_tweet => sub {
                  #some code....
            },
            on_error => sub {
                my $error = shift;
                debug "ERROR: $error";
            },
            timeout => 45,
        );
       $done->recv;

it fails. The uids file has the following contents:

'15855509,14760150,18598536'

I’m getting a 406 error from Twitter, suggesting the format is not correct. I’m guessing the quotes are not correct somehow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:05:56+00:00Added an answer on June 1, 2026 at 5:05 pm

    The AnyEvent::Twitter::Stream module subclasses AnyEvent and you don’t need to access the base module at all. All the functionality is provided by the new method and the callbacks that you specify there, and you shouldn’t call AnyEvent->condvar or $done->recv.

    The open call and assignment to @uid_line don’t belong inside the call to AnyEvent::Twitter::Stream->new.

    Furthermore the variable you are using to supply the value for the follow parameter is @uid_file instead of @uid_line.

    You must use strict; and use warnings; at the start of your programs, especially if you are asking for help with them. This will trap simple mistakes like this that you could otherwise overlook.

    You can’t in general use an array to supply a single scalar value. In this instance it may be OK as long as the file has only a single line (so there is only one element in the array) but there is a lot that could go wrong.

    In addition you are passing single-quotes in the value that don’t belong there: they appear in the code only to mark the start and end of the Perl string.

    I suggest you read all decimal strings from your file like this

    open my $uid_fh, '<', '/tmp/uids' or die $!;
    my @uids;
    push @uids, /\d+/g for <$uid_fh>;
    

    (Note that these lines belong before the call to AnyEvent::Twitter::Stream->new)

    Then you can supply the follow parameter by writing

    follow => join(',', @uids),
    

    I hope this is clear. Please ask again if you need further help.


    Edit

    These changes incorporated into your code should look like this, but it is incomplete and I cannot guarantee that it will work properly.

    use strict;
    use warnings;
    
    use AnyEvent::Twitter::Stream;
    
    open my $uid_fh, '<', '/tmp/uids' or die $!;
    my @uids;
    push @uids, /\d+/g for <$uid_fh>;
    
    my %cf = (
      account => 'myaccount',
      password => 'password',
    );
    
    my $nt_filter = AnyEvent::Twitter::Stream->new(
      username => $cf{account},
      password => $cf{password},
      method => 'filter',
      follow => join(',', @uids),
      on_tweet => sub {
        #some code....
      },
      on_error => sub {
        my $error = shift;
        debug "ERROR: $error";
      },
      timeout => 45,
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.