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.
 

[SOLVED] Pheal php class returning empty objects...

Author
SoC Darkord
Silentium Mortalitas
#1 - 2012-05-02 09:43:46 UTC  |  Edited by: SoC Darkord
Hi All,

So problems this time (Now with code):

Quote:
foreach ($result as $record) {
// Reset all variables:
$walletBalance = 0;
unset($Journal);
unset($Transactions);

spl_autoload_register("Pheal::classload");
//Set caching
PhealConfig::getInstance()->cache = new PhealFileCache(getcwd() . "/" . drupal_get_path('module', "mmi_user") . "/pheal/cache/");

try {
//variable to check what access was atempted if error is thrown
$attemptedtoaccess = '';

$keyid = $record->api_id;
$vcode = $record->verification_code;
$pheal = new Pheal($keyid, $vcode);

$char = $pheal->Characters();
$charsID = $char->characters[0]->characterID;
$character = $char->characters[0]->name;

$pheal->scope = "eve";

$charinfo = $pheal->CharacterInfo(array("CharacterID" => $charsID));
$walletBalance = $charinfo->accountBalance;

$pheal->scope = "char";

$attemptedtoaccess = 'WalletJournal';
$Journal = $pheal->WalletJournal(array("CharacterID" => $charsID, "accountKey" => '1000'));
$attemptedtoaccess = 'WalletTransactions';
$Transactions = $pheal->WalletTransactions(array("CharacterID" => $charsID, "accountKey" => '1000'));
} catch (PhealAPIException $e) {
$type = 'error';
if ($e->code == '221') {
watchdog($type, 'error: ' . $e->code . ' Cron message for ' . $character . ': ' . 'attempted to access ' . $attemptedtoaccess . ': ' . $e->getMessage());
} else {
watchdog($type, 'error: ' . $e->code . ' Cron message for ' . $character . ': ' . $e->getMessage());
}
}

// Moar code here



Ok So, the api call runs fine, returns no errors, the data seems to be passed through fine, and this format has worked ok for me before, however it now just returns an empty object.... im having this problem with the characterName() xml as well.

$Journal
$Transactions

^ Should be the objects...

Any ideas?

Offering Blackops and Covert services

 Covert bridging / Null sec camp clearing / Null sec Disruption / Anti capital / Covert fleet support

Trenker
#2 - 2012-05-02 14:27:50 UTC
Did not test your code, but by reading: the problem seems to be this call:

$pheal->scope = "char";

Take a look in the magic functions of the pheal class, there is no magic __set, only a magic __get (maybe it was there before, do not know, Peter Powers?)

There are two possibilities:

1) Create a new pheal instance for the "char" scope

$publicApi = new Pheal(null, null, 'eve');
$privateApi = new Pheal($keyId, $vCode, 'char');

2) Use the magic __get to change the scope

$charinfo = $pheal->eveScope->CharacterInfo($params);
$Journal = $pheal->charScope->WalletJournal($params);
$Transactions = $pheal->charScope->WalletTransactions($params);

SoC Darkord
Silentium Mortalitas
#3 - 2012-05-02 14:52:00 UTC  |  Edited by: SoC Darkord
hmm, I have the same code in use elseware:


Quote:
$pheal->scope = "eve";
$attemptedtoaccess = "CharacterInfo";
$charinfo = $pheal->CharacterInfo(array("CharacterID" => $charsID));

$apicontense = array();
$apicontense = array(
'charname' => $character,
'charid' => $charsID,
'corpid' => $corpid,
'alliid' => $charsheet->allianceID,
'charinfo' => $charinfo,
'charsheet' => $charsheet,
);


And that returns data fine. the $pheal->scope = ''; requests where done following documentation on the API docs pages..

Setting scope in that way shouldn't touch on the Pheal class files or call anything as its setting the value of an already generated object. The same as changing the value of an array or setting a standard variable to some bit of data or another...

Essentially all its doing is changing the current set scope for request, prior to passing into the _get function which takes what its currently set too, before making the request to ccp's servers.

My understanding of it is that the 'Scope' is the directory that the xml is in, and the function call (in this case WalletJournal()) is the name of the xml file being called. im not getting any errors at all during this process of grabbing the xml information, no failed requests or anything, just no data being returned...

So i guess what im saying is that im not sure $pheal->scope ='eve'; is the problem at all.

Unless i've got entirly the wrong end of the stick (very possible), in which case feel free to fling as much rotten fish as you can in my general direction

SoC

Edit:

I am testing your suggestion, not just fobbing it off, will let you know :)

Offering Blackops and Covert services

 Covert bridging / Null sec camp clearing / Null sec Disruption / Anti capital / Covert fleet support

SoC Darkord
Silentium Mortalitas
#4 - 2012-05-02 15:35:16 UTC
OK, so apparently my fault...

using an IDE it was showing no return, printing data from output buffer returned the object + everything in it as expected.

Im just failing at grabbing the data...

Thanks for the help :)

SoC

Offering Blackops and Covert services

 Covert bridging / Null sec camp clearing / Null sec Disruption / Anti capital / Covert fleet support