File: send_group_invitations

package info (click to toggle)
libwww-myspace-perl 0.82-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 728 kB
  • ctags: 170
  • sloc: perl: 4,646; makefile: 10
file content (48 lines) | stat: -rwxr-xr-x 1,350 bytes parent folder | download
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
#!/usr/bin/perl -I../lib

# To use:
# - Log into your myspace account and find/create a group.
# - Note the group ID (in the URL after "groupID=")
# - To send to all your friends: send_group_invitations groupID
# This script will cache your friend list - delete the cache file if you
# use a different account or want it to re-read the list.
# Note that you can also fill the cache file with a list of
# friendIDs.

# usage: send_group_invitations group_id [ friend_id ... ]

use WWW::Myspace;
use YAML qw'DumpFile LoadFile';

my $myspace = new WWW::Myspace( human => 0 );
die $myspace->error if $myspace->error;

my ( $group_id, @friends ) = @ARGV;

unless ( @friends ) {
	warn "Getting all friends\n";
	if ( -f './invite_friends_cache.yaml' ) {
		warn "Reading from cache file.  Delete group_invite_cache.yaml\n".
			  "if you don't want to do this.\n";
		@friends = LoadFile( 'group_invite_cache.yaml' );
	} else {
		@friends = $myspace->get_friends;
		DumpFile( 'group_invite_cache.yaml', @friends );
	}
}

warn "Inviting " . @friends . " friends.\n";

my ( $passed, $failed ) =
    $myspace->send_group_invitation( $group_id, @friends );
die $myspace->error if $myspace->error;

print "\n\nSent to:\n";
foreach $id ( @{ $passed } ) {
    print $id . "\n";
}

print "Failed to send to:\n";
 foreach $id ( @{ $failed } ) {
    print $id . "\n";
}