|
UsingYapealUtils
Starter Guide: Adding APIs Using Yapeal Utils - Examples on how to use the class/util/*.php file for application developers.
Phase-Design, Phase-Implementation, Phase-Deploy IntroductionThere are several new classes now available in Yapeal for application developers to use in classes/util/*.php that should make integrating Yapeal much easier. These classes provide simple OOP(object-oriented programming) interface to the underlaying tables and make managing them much easier. NoteThe first thing you might wanna read is this section: Util Database Table Dependences, since it contains information on how the util* tables works in your database and might help you understand a bit more of the content in this guide. If you have followed the Starter Guide you might already have read utilRegistered* sections in that wiki since it have been referred to from Starter Guide. NOTE: You can skip utilSections part in Util Database Table Dependences for now, since it will be covered in a later guide. DetailsThis guide and it's code is based on the setting registered_mode in yapeal.ini is set to optional. How this works is described in Util Database Table Dependences as mentioned above. Now lets start showing you what is required to make all the util classes work. The BasicIn any of your PHP files where you will be using any of the util classes you will need to include this code before using them:
That is the basic code needed to get each util class to work. The code comments should give you hints to what they do. Back To Top | Back to Handling Sections Guide class RegisteredKeyRegisteredKey is used to add/edit the CAK (Customizable API Key) for the utilRegisteredKey table so Yapeal has the key information it needs to be able to pulling data from the EVE APIs for you. You'll need to get the key information so you can add it to Yapeal. It is recommended you make a new CAK key at EVE API for Yapeal.
Now let me explain in a bit more detail what the above code does.$regKey = new RegisteredKey(1156);The number 1156 is your keyID. The keyID is the ID you find on EVE API. When running this line it will check if there is an existing record (row) with that ID in the utilRegisteredKey table of the database and if not it will create a new record when you use the store() function as shown at the end of the code.$regKey->vCode = 'abc123';This will set the vCode column in utilRegisteredKey table to 'abc123'. The vCode is the Verification Code you find on EVE API.$regKey->activeAPIMask = 8388608;This will set the activeAPIMask column in utilRegisteredKey table to 8388608. The activeAPIMask is the Access Mask you find on EVE API. NOTE: This is optional and you don't need to add this line as a default will be used if you don't include it here.$regKey->isActive = 1;This will ensure that the key you are about to add, is active so Yapeal will pull data for it. This allows you to have non-active keys stored in the table if you have a need to.$regKey->store()This will actually save the record into the utilRegisteredKey table. If you don't run this line, the data will not be saved and Yapeal will not retrieve any of the APIs for this key.$regKey = NULL; unset($regKey);This just releases the resources since they aren't needed any more. This looks similar to when adding a new CAK key to utilRegisteredKey table. The key thing to note here is that we are still using this:$regKey = new RegisteredKey(1156);This is because the RegisteredKey function works in 2 ways. When it's ran it will first check the utilRegisteredKey table, to see if there already is a record in it with that keyID. If the keyID exist it will pull the data from the database so we can edit it. If it doesn't exist it will create a new one that we can add the new key information to. The second thing to notice is that I used the:
Now lets look at the first new function I have added:
To get a list of the API names and their section names, you can take a look in the utilAccessMask table of your Yapeal database. The columns you'll need are section and api which corresponds to the above information. Please note the column: status. If the number is below 8, it does not work. Here is a short list of what the numbers mean: Now lets look at the last function I have added:
If you have a complete list of APIs as a bitmap to be add it is probably easier to use something like this:$apis = 8 | 4 | 1; $regKey->activeAPIMask = $apis;rather that using the the 2 above functions. For more information on what functions there are, you should look at the class/util/RegisteredKey.php file. All the functions are well documented in there. Before moving on, you should manually run yapeal.php from CLI to populate the account* tables class RegisteredCharacterRegisteredCharacter is used to add/edit a character in utilRegisteredCharacter table so Yapeal knows what to pull from EVE APIs for the specified character.
You might have noticed the code is simpler than when registering a key in the utilRegisteredKey table, and that is because you only need to feed it a characterID before storing it. It can't get much simpler than that. ;-) Again, if you have a complete list of APIs as a bitmap to be add it is probably easier to use something like this:$apis = 8 | 4 | 1; $char->activeAPIMask = $apis; To get a list of the API names to use, you can take a look in the utilAccessMask table of your Yapeal database. Look at the api column where the section name is char, which correspondence to the above. Please note the column: status. If the number is below 8, it does not work. For more information on what functions there are, you should look at the class/util/RegisteredCharacter.php file. All the functions are well documented in there. class RegisteredCorporationRegisteredCorporation is used to add/edit a corporation to the utilRegisteredCorporation table so Yapeal knows which APIs to pull from the EVE servers for the specified corporation. This is handles exactly the same as class RegisteredCharacter except that instead of using: $char = new RegisteredCharacter(126891489); it would be: $corp = new RegisteredCorporation(632257314); and the number is the corporationID that you also can find in the accountCharacters table. For more information on what functions there are, you should once again look at the class/util/RegisteredCorporation.php file. All the functions are well documented in there. SummaryYou have been shown how to use the util classes: RegisteredKey, RegisteredCharacter and RegisteredCorporation in this guide. If you run yapeal.php now you might wonder why your tables are not populating and there is a good reason for this. You will need to turn on the sections that you want to pull data from in another util table and that will be explained in the next guide. Next is: Handling Sections | |