These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Help needed pulling from eve api using xml and php

Author
Dustey Roads
Zero Corps
#1 - 2013-11-04 22:16:01 UTC  |  Edited by: Dustey Roads
Hi guys,

I am a complete novice at coding and have been having a nightmare of a time trying to pull data for a specific division of my corp wallet using php and xml. I thought I had got to grips with what I needed to do, but every time I try to pull the data I either end up with an error or a blank screen.

I hate to ask, but as I am a complete noob, could somebody link me to or send me the complete php code I need to use?

Thanks for your time.
Princess Honneamise
#2 - 2013-11-04 23:46:55 UTC  |  Edited by: Princess Honneamise
it is all the day im working on a emdr client in C, so my brain is smoking...

edited today cause yesterday i was really tired and i wrote a mess... :P

btw according to this :
http://wiki.eve-id.net/APIv2_Corp_AccountBalance_XML
you can get for example the balance of each division wallet of the corp.

you should setup a request like :

Quote:

$keyID="your key";
$vcode="your vcode";
$characterID="your charatcer id";

$url = "http://api.eveonline.com/corp/AccountBalance.xml.aspx?keyID=".$keyID."&vcode=".$vcode."&characterID=".$characterID."";

$file = file_get_contents($url);

print($file);

//now play in xml with $file



NOTE : the apikey MUST be of corporation type .

EVE MOONS PROJECT

http://eve-moons.com

The EVE MOONS PROJECT is the most complete and accurate moons database for Eve Online

Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#3 - 2013-11-05 01:39:41 UTC
The short answer is: you can't pull a single division.

The longer answer is: you have to pull the entire thing, then filter it down.

The even longer answer involving code will have to wait for tomorrow, when I'll have a poke at it.

I'm assuming you're wanting to look at the wallet journal or wallet transactions for the corp, rather than just the balance?

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Louis Vitton
Viziam
Amarr Empire
#4 - 2013-11-05 07:50:16 UTC
If your a novice, use Phealng https://github.com/3rdpartyeve/phealng
It has a nice to array function to assist with getting the parts you need.
It is a php libary
Princess Honneamise
#5 - 2013-11-05 10:08:29 UTC
Steve Ronuken wrote:
The short answer is: you can't pull a single division.

The longer answer is: you have to pull the entire thing, then filter it down.

The even longer answer involving code will have to wait for tomorrow, when I'll have a poke at it.

I'm assuming you're wanting to look at the wallet journal or wallet transactions for the corp, rather than just the balance?


dont you can pull "/corp/WalletJournal.xml.aspx " adding the accountKey parameter ?

Quote:

It isn't necessary to specify accountKey for characters because they have only one wallet (accountKey=1000). However, corporations have seven wallets with accountKey(s) numbered 1000 through 1006. Use /corp/AccountBalance.xml.aspx to determine which accountKey corresponds to each corporate wallet.


EVE MOONS PROJECT

http://eve-moons.com

The EVE MOONS PROJECT is the most complete and accurate moons database for Eve Online

Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#6 - 2013-11-05 10:30:35 UTC
Princess Honneamise wrote:
Steve Ronuken wrote:
The short answer is: you can't pull a single division.

The longer answer is: you have to pull the entire thing, then filter it down.

The even longer answer involving code will have to wait for tomorrow, when I'll have a poke at it.

I'm assuming you're wanting to look at the wallet journal or wallet transactions for the corp, rather than just the balance?


dont you can pull "/corp/WalletJournal.xml.aspx " adding the accountKey parameter ?

Quote:

It isn't necessary to specify accountKey for characters because they have only one wallet (accountKey=1000). However, corporations have seven wallets with accountKey(s) numbered 1000 through 1006. Use /corp/AccountBalance.xml.aspx to determine which accountKey corresponds to each corporate wallet.





Bah. Time to update the evelopedia documentation for the corp api. which completely skips the account key parameter.

Ignore my earlier post.

And use phealng. it makes life a lot easier :)


If you want to avoid having to install the library:
https://gist.github.com/fuzzysteve/7317000

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Princess Honneamise
#7 - 2013-11-05 10:38:50 UTC
i have just tested it and it works :P
so for the first guy who asked , if you need to grab the wallet journal of a specific division you can use :

Quote:

$keyID="your key";
$vcode="your vcode";
$characterID="your charatcer id";
$accountKey="1000"; //the division you want

$url = "http://api.eveonline.com/corp/WalletJournal.xml.aspx?keyID=".$keyID."&vcode=".$vcode."&characterID=".$characterID."&accountKey=".$accountKey."";

$file = file_get_contents($url);

print($file);

//now play in xml with $file



As before the apikey must be of type corporation.

EVE MOONS PROJECT

http://eve-moons.com

The EVE MOONS PROJECT is the most complete and accurate moons database for Eve Online

Dustey Roads
Zero Corps
#8 - 2013-11-05 19:06:23 UTC
Hi guys,

Thanks very much for your responses. No, I don't need to see the transactions. Basically, one of my corps, including the POS' and wars are run from donations and I just wanted a simple way to show how much had been donated to a specific division ready for the following months antics.

I will have a look at phealing but already tried the stuff from the wiki before realising it was out of date. I did find some documentation that was up to date, but was unable to get the information to display in the browser.
Dustey Roads
Zero Corps
#9 - 2013-11-05 19:37:08 UTC  |  Edited by: Dustey Roads
Ok guys, with your help I made some progress. The file is now displaying the date and time of the api pull when the contents are fetched and printed, but the balance still doesn't show.

Here is what I changed:

I stopped using the wallet call and am now using CorporationAccountBalance
I also stopped using concatenated variables and just put in the required url and printed it. The code now looks something like this:

Quote:
$url = "http://api.eveonline.com/corp/AccountBalance.xml.aspx?keyID=myKeyID&vcode=myVCode&accountKey=1001";

$file = file_get_contents($url);

print($file);

Is there something I am missing which is stopping the balance from displaying?

P.S. Steve, thanks for the alternative, I tried that too but still end up with a blank screen:
http://ccode.e-central.co.uk/donations_test.php
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#10 - 2013-11-05 20:06:40 UTC
You may or may not have all the php modules you need, built in.

It can be a problem.

What to try:

Go to the URL yourself, and you should get some XML. try putting that into the php directly (use http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc to quote it) and processing it.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Jade III
Sebiestor Tribe
#11 - 2013-11-05 20:27:03 UTC
How do you make the information from the xml file actually show on the webpage?

My adventure blog: http://lonewolfadventures.wordpress.com/

Dustey Roads
Zero Corps
#12 - 2013-11-05 20:53:47 UTC
Jade III wrote:
How do you make the information from the xml file actually show on the webpage?


I have tried print and echo but neither work.
Princess Honneamise
#13 - 2013-11-05 21:58:11 UTC
according to dustey it seems some problem persist about balance updating.
for your info the code used now is :

Quote:


$keyID="---";
$vcode="---";
$characterID="---";

$url = "http://api.eveonline.com/corp/AccountBalance.xml.aspx?keyID=".$keyID."&vcode=".$vcode."&characterID=".$characterID."";

$file= file_get_contents($url);

$xml = simplexml_load_string($file);


print("please refresh after :".$xml->cachedUntil." ( eve time)\n");

foreach ($xml->result->rowset[0] as $value)
{

print($value['accountID']);
print(" --- ");
print($value['accountKey']);
print(" --- ");
print($value['balance']);
print("\n");

};//close loop

EVE MOONS PROJECT

http://eve-moons.com

The EVE MOONS PROJECT is the most complete and accurate moons database for Eve Online

Dustey Roads
Zero Corps
#14 - 2013-11-05 22:01:34 UTC
Thanks again for all the help.

Still waiting to see if the balance updates once a donation has been made after the API call refreshes, but the information is now printing to the screen as it should.
Dustey Roads
Zero Corps
#15 - 2013-11-05 22:11:02 UTC
So even with a donation to the corp wallet and a refresh timer, the balance shown by the xml fetched is still wrong which is a little peculiar.
Peter Powers
Terrorists of Dimensions
#16 - 2013-11-06 10:22:06 UTC
Dustey Roads wrote:
So even with a donation to the corp wallet and a refresh timer, the balance shown by the xml fetched is still wrong which is a little peculiar.

can you be a bit more detailed on how it is wrong?

3rdPartyEve.net - your catalogue for 3rd party applications