The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WWW::Myspace::FriendAdder - Interactively add friends to your Myspace account

VERSION

Version 0.02

SYNOPSIS

This module gives you a little more flexibility when adding friends to your Myspace account. It is interactive and will occasionally prompt you for input. You'll have the most success when using it at the command line, but you do have the option of suppressing its reporting and interactive nature if you want to run it from a cgi script or if you just find it annoying. Hey, you've got your reasons, right? This module is an extension of Grant Grueninger's handy WWW::Myspace module.

    use WWW::Myspace;
    use WWW::Myspace::FriendAdder;

    my $myspace = WWW::Myspace->new();

    my $adder = WWW::Myspace::FriendAdder->new( $myspace );

    my @friend_ids = ('List', 'of', 'friend', 'ids');

    $adder->send_friend_requests( @friend_ids );

By default, this routine will try to add as many friends as possible. When Myspace prompts you for user input, the routine will pause and allow you as much time as you need to fill out the Myspace form. Once you have done so, you may prompt the script to continue or to exit. Upon its exit, the script will report on its success and/or failure.

CONSTRUCTOR AND STARTUP

new()

Initialize and return a new WWW::Myspace::FriendAdder object. $myspace is a WWW::Myspace object.

Example

    use WWW::Myspace;

    use WWW::Myspace::FriendAdder;

    my $myspace = WWW::Myspace->new(); # see WWW::Myspace docs for more info on logging in with username/pass

    my $adder = WWW::Myspace::FriendAdder->new( $myspace );
    
    # or
    # pass some startup parameters
    my %startup_params = (
        exclude_my_friends  => 1, 
        max_attempts        => 25, 
        config_file         => '/path/to/config_file.cfg',
    );
    
    my $adder = WWW::Myspace::FriendAdder->new( $myspace, \%startup_params );

    # find all of Shania Twain's friends (hey, you've got your reasons...)
    my @friend_ids = $myspace->friends_from_profile('13866406');
    
    # now, ask Shania's friends to be your friends
    $adder->send_friend_requests( @friend_ids);

Optional Parameters

  • exclude_my_friends => [0|1]

    You can only perform a set number of friend requests per day. I don't know what that number is. I'm pretty sure it's more than 200, but it may be less than 250. I can't tell you for sure, so don't go crazy and try 1,000 requests in an hour. A failed request will still count as an attempt, so don't go wasting your daily attempts. Unless you like to waste. In that case, go crazy. If you want to get the most out of your attempts, set this value to be true. Currently this info is not cached, so your friend ids will have to be looked up every time you run the script. If you have a lot of friends, keep in mind that this will mean some extra time before your scripts starts trying to add friends. Default is off.

  • interactive => [0|1]

    This module is at its most powerful when you are able to interact with it. If you don't feel like interacting, set this to 0. Default is on.

  • max_attempts => $value

    Set this to any positive integer and FriendAdder will stop friend requests when it reaches this upper limit. Default is 50.

  • random_sleep => [0|1]

    Want your script to feel more human? Set random_sleep to 1 and send_friend_requests() will take random breaks between add requests using Perl's built-in rand() function. The upper limit of the random number will be set by the sleep option (see below). Default is off.

  • sleep => $value

    Myspace's network connectivity is wonky at the best of times. Best not to send a request every 0.1 seconds. Set this to any positive number and send_friend_requests() will sleep for this many seconds between add requests. If you enable random_sleep (see above), this number will be the upper limit of the random sleep time. Default is 10.

send_friend_requests( @friend_ids )

This method is the main force behind this module. Pass it a list of friend_ids and it will try to add them to your friends. This method is really just a wrapper around $myspace->send_friend_requests() It adds interactivity and advanced reporting to the WWW::Myspace method. You'll get most of the info that you need printed to your terminal when you run your script from the command line. But, the script will also return a hash reference which you can use to create your own reports. The hash is keyed on response codes returned by WWW::Myspace. The value of each key is a list of friend ids which returned with that status code.

    my $report = $adder->send_friend_requests( @friend_ids );
    
    # when run at the command line, you may see something like this:
    
    $ perl add.pl 

    Beginning to process the ids...
    1)      9395579:        Failed, this person is already your friend. (FF)       Sleeping for 4.95 seconds...
    2)      9373522:        Passed! Verification string received. (P)       Sleeping for 2.43 seconds...
    3)      9315640:        Failed, you already have a pending friend request for this person (FP)  Sleeping for 5.71 seconds...
    4)      9277516:        Passed! Verification string received. (P)       Sleeping for 1.78 seconds...
    5)      9269809:        Passed! Verification string received. (P) 
    
    Max attempts (5) reached. Exiting nicely...
    
    Final status report...
    
    ######################
    5 total attempts
    1 Failed, this person is already your friend. (FF)
    1 Failed, you already have a pending friend request for this person (FP)
    3 Passed! Verification string received. (P)

    # %report may look something like this...
    my %{$report} = (
        'FF' => [
                    '9395579'
                ],
        'FP' => [
                    '9315640'
                ],
        'P' => [
                   '9373522',
                   '9277516',
                   '9269809'
                 ],
        );

add_to_friends( @friend_ids)

Convenience method - same as send_friend_requests.

AUTHOR

Olaf Alders, <olaf at wundersolutions.com> inspired by the excellent code of Grant Grueninger

BUGS

Please report any bugs or feature requests to bug-www-myspace at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Myspace. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

NOTES

This module is still in its infancy. It does a lot of cool stuff, but the interface is still subject to change. Please keep this in mind when upgrading

TO DO

Caching features

Blocking friend requests to ids that are already pending

Tighten up accessor/mutator functions for this module

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WWW::Myspace::FriendAdder

You can also look for information at:

ACKNOWLEDGEMENTS

Many thanks to Grant Grueninger for giving birth to WWW::Myspace and for his help and advice in the development of this module.

COPYRIGHT & LICENSE

Copyright 2006 Olaf Alders, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.