WWW::BF2Player - Fetch information about game servers from BF2Player.com


WWW-BF2Player documentation  | view source Contained in the WWW-BF2Player distribution.

Index


NAME

Top

WWW::BF2Player - Fetch information about game servers from BF2Player.com

SYNOPSIS

Top

  # example 1
  use WWW::BF2Player;
  my $bfp = WWW::BF2Player->new; # omitted UserId, must set it per-request
  my $player = $bfp->getPlayer( UserId => '5307', PlayerId => '64246757' ); # userId specified per-request

  # example 2
  use WWW::BF2Player;
  my $bfp = WWW::BF2Player->new( UserId => '5307' ); # set a default UserId, can omit UserId per-request
  my $player = $bfp->getPlayer( PlayerId => '64246757' ); # use the default UserId

DESCRIPTION

Top

First, you must have an account (free) at BF2Player.com to make use of this module. Second, you must create and populate a buddy list on their site. You can only use this module to ask for information about players in your buddy list. This is a restriction on their part to prevent you from asking information for too many players. I guess to prevent you from competing and wasting their resources. Understandable, I suppose.

new

  my $gm = WWW::BF2Player->new; # no options or defaults specified

  my $gm = WWW::BF2Player->new( UserId => '5307' ); # default to a certain UserId

You can specify several options in the constructor.

  my $gm = WWW::BF2Player->new(
      Expires => 300,
      UserId => '5307',
      CacheFile => 'my_player_cache.xml',
      DebugLog => 'my_debug_log.txt',
      DebugLevel => 3,
  );

Expires [optional]

Sets the data cache freshness in seconds. If the cache has data older than this number of seconds, it is no longer valid. It's best that you set this value to something higher than 1 minute and would be even better if you were satisfied with setting it around 5 minutes. If the cache is fresh enough, it won't even ask the Game-Monitor.com server for any information. Keep in mind that Game-Monitor doesn't update their information more than once every several minutes. It won't be useful for you to set the Expires value too low.

UserId [optional]

Sets the default UserId use. If you don't specify a UserId when asking for data, it will use this value instead. You have to specify it somewhere (here or per-request) or it won't work.

CacheFile [optional]

Sets the path and filename for the data cache. This is "bf2PlayerCache.xml" by default.

DebugLog [optional]

Sets the path and filename for the debug log. This is "bf2PlayerDebug.log" by default. To enable logging, you'll have to choose a DebugLevel greater than zero (zero is default).

DebugLevel [optional]

Sets the level of debugging. The larger the number, the more verbose the logging. This is zero by default, which means no logging at all.

getPlayerRaw

  my $player = $gm->getPlayerRaw( PlayerId => '64246757' ); # omitted UserId, use the UserId specified in the constructor  
  my $player = $gm->getPlayerRaw( UserId => '5307', PlayerId => '64246757' ); # specified UserId, use a different UserId

This fetches the player data from the BF2Player.com server. It's returned as-is from the server, so the data isn't pretty, but it's technically accurate. If you just want the raw data, this is the function for you. If you want it prettified a bit, getPlayer might be a better fit. See also getPlayer.

UserId [optional]

If you specify it here, it overrides what was set in the constructor. If you didn't specify it in the constructor, it is required here.

PlayerId [required]

Which PlayerId to ask about. This is their official Battlefield 2 PID, not their username.

getPlayer

  my $player = $gm->getPlayer( PlayerId => '64246757' ); # omitted UserId, use the UserId specified in the constructor  
  my $player = $gm->getPlayer( UserId => '5307', PlayerId => '64246757' ); # specified UserId, use a different UserId

This is the same thing as getPlayerRaw, except it prettifies the returned data. See also getPlayerRaw.

UserId [optional]

If you specify it here, it overrides what was set in the constructor. If you didn't specify it in the constructor, it is required here.

PlayerId [required]

Which PlayerId to ask about. This is their official Battlefield 2 PID, not their username.

AUTHOR

Top

Dusty Wilson, <www-bf2player-module@dusty.hey.nu>

COPYRIGHT AND LICENSE

Top


WWW-BF2Player documentation  | view source Contained in the WWW-BF2Player distribution.