1 package WWW
::BackpackTF
;
6 use parent qw
/Exporter/;
7 our $VERSION = '0.000_001';
8 our @EXPORT_OK = qw
/TF2 DOTA2/;
10 use constant TF2
=> 440;
11 use constant DOTA2
=> 570;
13 use JSON qw
/decode_json/;
14 use LWP
::Simple qw
/get/;
15 use WWW
::BackpackTF
::User
;
18 my ($class, $key) = @_;
19 bless {key
=> $key}, $class
23 my ($self, @users) = @_;
24 my $response = decode_json get
"http://backpack.tf/api/IGetUsers/v3/?compress=1&format=json&steamids=" . join ',', @users;
25 $response = $response->{response
};
26 die $response->{message
} unless $response->{success
};
27 @users = map { WWW
::BackpackTF
::User
->new($_) } values $response->{players
};
28 wantarray ?
@users : $users[0]
36 WWW::BackpackTF - interface to the backpack.tf trading service
41 my $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
42 my $user_id = <STDIN>;
43 my $bp = WWW::BackpackTF->new($api_key);
44 my $user = $bp->get_users($user_id);
45 print 'This user is named ', $user->name, ' and has ', $user->notifications, ' unread notification(s)';
49 WWW::BackpackTF is an interface to the backpack.tf Team Fortress 2/Dota 2 trading service.
51 The only call implemented so far is I<IGetUsers>.
57 =item B<new>(I<[$api_key]>)
59 Create a new WWW::BackpackTF object. Takes a single optional parameter, the API key.
61 =item B<get_users>(I<@users>)
63 Get profile information for a list of users. Takes any number of 64-bit Steam IDs as arguments and returns a list of WWW::BackpackTF::User objects. This method does not require an API key.
75 Constant (440) representing Team Fortress 2.
79 Constant (570) representing Dota 2.
85 L<http://backpack.tf/>, L<http://backpack.tf/api>
89 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
91 =head1 COPYRIGHT AND LICENSE
93 Copyright (C) 2014 by Marius Gavrilescu
95 This library is free software; you can redistribute it and/or modify
96 it under the same terms as Perl itself, either Perl version 5.18.2 or,
97 at your option, any later version of Perl 5 you may have available.
This page took 0.023686 seconds and 4 git commands to generate.