| Pages: [1] :: one page |
| Author |
Thread Statistics | Show CCP posts - 0 post(s) |

Dsan
Bedlam.
0
|
Posted - 2011.04.08 10:59:00 -
[1] - Quote
Hello Tech forums. You have become my favorite sub forum of eve-o forums 
I would love to work more with the API and start creating my own code instead of using others small packages for showing different things from the API.
But I'm not a OOP pro at all, or at a point where you can just hand me a library and the manual and I can figure it out myself.
So I would like some tricks to very very basic php for API usage.
What I gathered so far is: Create a cache from your API, to avoid getting blacklisted.
So I guess I need to call the right XML files at api.eveonline.com, interpret them and insert/update them into a cache table at my database.
So a fairly simple function to call an xml file and save it to database or a place where theres a noob guide ? |

Catari Taga
Centre Of Attention Middle of Nowhere
222
|
Posted - 2011.04.08 11:46:00 -
[2] - Quote
Dsan wrote:So a fairly simple function to call an xml file and save it to database or a place where theres a noob guide ? At that level you should really be using one of the available libraries that will handle that for you.
But if you want to figure it all out by yourself, the simplest way to make an API request and store it is probably like this:
file_put_contents($filename,file_get_contents($api_url));
But there are better ways, which is why the API libraries are longer than a one-liner.  |

Dsan
Bedlam.
0
|
Posted - 2011.04.08 12:15:00 -
[3] - Quote
yeah, I found the this:http://wiki.eve-id.net/PHP_Parsing:_Assets_XML
Which I'll get to work and then break it down and try and built up what I want and need.
But anything is usefull. before using libraries, I have to understand OOP better than I do now, I think :( |

TorTorden
NorCorp Enterprise Norcorp
1
|
Posted - 2011.04.08 12:41:00 -
[4] - Quote
I can definitely understand using libraries but I chose personaly to figure out how to do it with simplexml instead.
My main reason for this was that I figured It would be nice to know how to parse xml's outside of eve specific cases and I personaly have a massive case of the 'need to know'.
My main handicap for this was I dont know OOP, But that goes for the libs as well I guess.
As for starting out with, I would recommend starting with one of the lighter xml's and leave things like the asset list for later. (I.e Where a <row> leads into another <rowset> things can start to get funky)
Would probably be easier to start with something like server status and when you get data out of that, start off with something else, like your character sheet.
I so far have no experience with wallet lists and killlog.xml's etc but the asset list in particular is useless without the static data dump, as well as the conq stations lists etc etc.
For figuring out the eve-api I used mostly this http://wiki.eve-id.net/APIv2_Page_Index
And for simplexml in php this. http://no.php.net/manual/en/book.simplexml.php
And of course a shitload of googling.
|

Mikk36
E-x7 Network Saints Amongst Sinners
5
|
Posted - 2011.04.08 12:49:00 -
[5] - Quote
And of course, don't forget to mind this thread.
With SimpleXML, the easiest solution is propably to copy the needed rows out to an array and sort that array with a custom comparator with the usort() function. For example, when sorting WalletJournal by refID in descending order, I use this function with usort(): function refIDSort($a, $b) { return (floatval($a['refID']) > floatval($b['refID'])) ? -1 : 1; } |

Catari Taga
Centre Of Attention Middle of Nowhere
222
|
Posted - 2011.04.08 14:32:00 -
[6] - Quote
OOP is just one way of writing code. It's not like it is required to write your code in that style and depending on the complexity of your code it may not even make sense.
But yeah, in php I use SimpleXML myself mostly, sometimes substr() is faster if I only need specific values and do not know where they are in the xml tree (e.g. my apiproxy retrieves the cachedUntil value via substr(), also because some APIs sometimes break and put it in the wrong place).
Mikk36 wrote:With SimpleXML, the easiest solution is propably to copy the needed rows out to an array and sort that array with a custom comparator with the usort() function.
I'm not sure I understand you correctly, but why do you not either apply usort() to the SimpleXML object directly, or, if you write a custom array, simply use the refID as the index and sort with ksort().? |

Mikk36
E-x7 Network Saints Amongst Sinners
5
|
Posted - 2011.04.08 16:05:00 -
[7] - Quote
It appeared to me when browsing the web that one can't sort a SimpleXML object. |

Catari Taga
Centre Of Attention Middle of Nowhere
222
|
Posted - 2011.04.08 16:39:00 -
[8] - Quote
You can sort a SimpleXML object like any other array. |

Xndo2
Dark Shadow Industries Wildly Inappropriate.
0
|
Posted - 2011.04.08 16:47:00 -
[9] - Quote
Personally I'm also new to this calling the api, I had a thought about getting a characters skills and check that with a database then display what ships you can fly base on that. this is more of a wondering thing about that. I've looked into my own api and saved it in a xml file and found this
<rowset name="skills" key="typeID" colums="typeID,skillpoints,level,unpublished">
then the list of skills i have
</rowset>
I've been looking at the various api libs and haven't found what I'm looking for... any ideas ??? |

Iveran
Interwebs Cooter Explosion Important Internet Spaceship League
0
|
Posted - 2011.04.08 18:00:00 -
[10] - Quote
I'm also a total noob, but I've been teaching my-self over the past few weeks. The easiest way that I've found to pull & store information from the EVE API is this:
Quote: example 1: basic pulling
$request = curl_init();
curl_setopt($request, CURLOPT_URL, sprintf("http://api.eve-online.com/char/CharacterSheet.xml.aspx?userID=%d&apiKey=%s&characterID=%d", $api['api_id'], $api['api_key'], $characters['char_id'])); curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($request); curl_close($request);
$xml = new SimpleXMLElement($response); foreach($xml->result->rowset->row as $skill){ //put your stuff here }
example 2: pulling from other rowsets: If you need to pull something like corporation roles which is also under a rowset, but it's 3 rowsets down. So, you'd do this:
foreach($xml->result->rowset[3]->row as $skill){ //put your stuff here }
You have to tell it which rowset to pull from.
If you have any more questions just ask, I'll do my best to answer. |
| |
|
| Pages: [1] :: one page |
| First page | Previous page | Next page | Last page |