VarjoAPI
From EVEDev
| API Resources - Category Home - API Libraries - API Usage Examples - API Method Reference |
| VarjoAPI | |
|---|---|
| Maintainer: | Varjokaasu |
| Stable release: | 1.00 |
| Development release: | |
| OS: | Platform independent, Perl required |
| License: | Perl |
| Website: | http://wiki.eve-id.net/VarjoAPI |
Contents |
Description
Minimal perl module for accessing the EVE Online API.
Installation
Copy VarjoAPI.pm into any directory your perl interpreter checks for modules.
Documentation
Needed modules are WWW::Curl::Easy and XML::Simple. Recommended module for testin Data::Dumper.
Note! This module doesn't include data cache. You should store data and use that stored data until time "cachedUntil" has been reached. Check API_Cache_Styles for more information.
Example
Verbose:
#!/usr/bin/perl use VarjoAPI; use Data::Dumper; my $xml=varjoApi("/account/Characters.xml.aspx","12345","aabbccdd",""); print Dumper($xml);
First parameter for varjoApi is url. Change 12345 to your UserID. Change aabbccdd to your ApiKey. Last parameter is CharacterID, leave empty string if not needed.
Should return nice perl style data dump of returned infomation.
VarjoAPI.pm
#!/usr/bin/perl =head1 NAME VarjoAPI - Minimal module for accessing the EVE Online API =head1 DESCRIPTION This minimal module provides very simple interface to the EVE Online API. =head1 USAGE Module must be installed into a path that your system checks for modules. use VarjoAPI; my $xml=varjoApi("/account/Characters.xml.aspx","12345","aabbccdd",""); print Dumper($xml); First parameter is api url. Second parameter is UserID. 3rd parameter is ApiKey. Last parameter is optional CharacterID. Give empty string if not needed. Needed modules are WWW::Curl::Easy and XML::Simple. Recommended module for testin Data::Dumper. =head1 COPYRIGHT Copyright (c) 2010 Turo Janka, IGM : Varjokaasu . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut use strict; use warnings; use WWW::Curl::Easy; use XML::Simple; sub varjoApi { my($page, $userid, $apikey, $characterid) = @_; my $curl = new WWW::Curl::Easy; my $data = "userID=".$userid."&apiKey=".$apikey."&characterID=".$characterid; $curl->setopt(CURLOPT_URL, "http://api.eve-online.com/".$page); $curl->setopt(CURLOPT_CONNECTTIMEOUT, 30); $curl->setopt(CURLOPT_POSTFIELDS, $data); my $response_body; open (my $fileb, ">", \$response_body); $curl->setopt(CURLOPT_WRITEDATA,$fileb); my $retcode = $curl->perform; if ($retcode == 0) { print("Transfer went ok\n"); my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); } else { print("An error happened: ".$curl->strerror($retcode)." ($retcode)\n"); exit 1; } my $xmlref = XMLin($response_body); return $xmlref; } 1;
That's all.