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.
 

Pulling Player Transactions with PHP

Author
Viomi
Garoun Investment Bank
Gallente Federation
#1 - 2013-08-25 00:08:16 UTC
example of the Journal Data;

Taken from here;
http://wiki.eve-id.net/APIv2_Char_JournalEntries_XML

Quote:
date="2008-08-22 03:36:00" refID="1578932679" refTypeID="54" ownerName1="corpslave"
ownerID1="150337897" ownerName2="Secure Commerce Commission" ownerID2="1000132"
argName1="" argID1="0" amount="-8396.99" balance="576336941.61" reason="" taxReceiverID="" taxAmount=""


I'm struggling to figure out how to pull certain fields from this kind of data, what I'm trying to do is to pull the data for the journal and then filter it to where the refTypeID=10 and then in those cases I want to store that line's; date, amount and ownerName1.

I'm not sure if I'm going in the complete wrong direction but this is my code for attempting to do this;


Quote:
< ?php

$data = file_get_contents('https://api.eveonline.com/char/WalletJournal.xml.aspx?');
xml = new SimpleXMLElement($data);

foreach($xml->result->rowset->row[0]{refTypeID}){
where (refTypreID = 10){
// add data to an array or something similar temporarily;
}
}

? >


However this isn't working as intended and I'm not sure where to go from here.

Would love a little bit of help!
Thanks,
Viomi
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#2 - 2013-08-25 00:54:06 UTC
Your problem is:

foreach($xml->result->rowset->row[0]{refTypeID}){


That's not how foreach works.

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

if ($row{refTypeID}==10){



Should be closer. (I've not looked at the data structure)


There's no where() in php. Just if()
refTypeID isn't being defined anywhere
using an = in an conditional in php assigns the value. Use == if you want it to match the value. === if you want it to match the value and the data type.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Viomi
Garoun Investment Bank
Gallente Federation
#3 - 2013-08-25 10:25:31 UTC
Ah, that was silly of me. It was very late at the time and I was a bit frustrated so... :( No excuse though.

I've got it working now;

Quote:
//For Wallet Journal
$urlChar = "https://api.eveonline.com/$apiSection.xml.aspx?keyID=$keyID&vCode=$vCode&characterID=$charID&rowCount=500";
$data = file_get_contents($urlChar);
$xml = new SimpleXMLElement($data);
//Char Corp Transactions
foreach ($xml->result->rowset->row as $row){
if($row{'refTypeID'} == 37){
echo "Transfered: " . $row{'amount'} . " From Wallet: " . $row{'ownerName1'} . " To Wallet: " . $row{'ownerName2'} . " By: " . $row{'argName1'};
}
}


However the rowCount increase from 50 to 500 does not seem to work, I can decrease it to say 5 or 45 but cannot extend it past the 50 rows, any idea? Have I done something else silly?

Thanks,
V
Manhim
Garoun Investment Bank
Gallente Federation
#4 - 2013-08-25 11:20:58 UTC
If you want to go further you'll need to walk through the data.

I've got a code that covers Journal if you want to base yourself on it: https://gist.github.com/Manhim/5483452
0mni Ca
Brutor Tribe
Minmatar Republic
#5 - 2013-08-25 18:08:15 UTC
Here is code that works, something I use to pull some journal data:
Quote:
$db->query('SELECT MAX(refID) AS refID FROM `journal`') ;
$maxid = $db->fetch_row();

$data = file_get_contents("https://api.eveonline.com/corp/WalletJournal.xml.aspx?keyID=" . $conf->UserID . "&vCode=" . $conf->ApiKey . "&accountKey=1000&rowCount=2560&fromID=" . $maxid['refID']) ;

$xml = new SimpleXMLElement($data);

$db->query('INSERT INTO `journal_1000`
(`refID`, `journalDate`, `refTypeID`, `ownerName1`, `ownerID1`, `ownerName2`, `ownerID2`, `argName1`, `argID1`, `amount`, `balance`, `reason`, `owner1TypeID`, `owner2TypeID`)
VALUES (:field1, :field2, :field3, :field4, :field5, :field6, :field7, :field8, :field9, :field10, :field11, :field12, :field13, :field14)');

foreach ($xml->result->rowset->row as $row)
{
if ( $row['refID'] > $maxid['refID'] )
{
$db->execute(array(
':field1' => $row['refID'],
':field2' => $row['date'],
':field3' => $row['refTypeID'],
':field4' => $row['ownerName1'],
':field5' => $row['ownerID1'],
':field6' => $row['ownerName2'],
':field7' => $row['ownerID2'],
':field8' => $row['argName1'],
':field9' => $row['argID1'],
':field10' => $row['amount'],
':field11' => $row['balance'],
':field12' => $row['reason'],
':field13' => $row['owner1TypeID'],
':field14' => $row['owner2TypeID']
));
}
}
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#6 - 2013-08-25 18:09:40 UTC
As a tip, for passing around stuff the forums don't like, pastebin.com works well.

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Viomi
Garoun Investment Bank
Gallente Federation
#7 - 2013-08-25 22:32:30 UTC
0mni Ca wrote:
Here is code that works, something I use to pull some journal data:
Quote:
$db->query('SELECT MAX(refID) AS refID FROM `journal`') ;
$maxid = $db->fetch_row();

$data = file_get_contents("https://api.eveonline.com/corp/WalletJournal.xml.aspx?keyID=" . $conf->UserID . "&vCode=" . $conf->ApiKey . "&accountKey=1000&rowCount=2560&fromID=" . $maxid['refID']) ;

$xml = new SimpleXMLElement($data);

$db->query('INSERT INTO `journal_1000`
(`refID`, `journalDate`, `refTypeID`, `ownerName1`, `ownerID1`, `ownerName2`, `ownerID2`, `argName1`, `argID1`, `amount`, `balance`, `reason`, `owner1TypeID`, `owner2TypeID`)
VALUES (:field1, :field2, :field3, :field4, :field5, :field6, :field7, :field8, :field9, :field10, :field11, :field12, :field13, :field14)');

foreach ($xml->result->rowset->row as $row)
{
if ( $row['refID'] > $maxid['refID'] )
{
$db->execute(array(
':field1' => $row['refID'],
':field2' => $row['date'],
':field3' => $row['refTypeID'],
':field4' => $row['ownerName1'],
':field5' => $row['ownerID1'],
':field6' => $row['ownerName2'],
':field7' => $row['ownerID2'],
':field8' => $row['argName1'],
':field9' => $row['argID1'],
':field10' => $row['amount'],
':field11' => $row['balance'],
':field12' => $row['reason'],
':field13' => $row['owner1TypeID'],
':field14' => $row['owner2TypeID']
));
}
}


Ah okay I think I get most of whats going on there - I'd just have to make a new DB table for that journal_1000 I take it. If you were doing this for multiple characters and quite often would you just wipe the data after each use?
Louis Vitton
Viziam
Amarr Empire
#8 - 2013-08-27 02:19:27 UTC
Why not try yapeal or pheal (php frameworks)
yapeal will import the wallet to the database for you straight out.
PhealING has a very nice to array function so that you can change the XML to a php array, makes it much easier to change and manipulate for d