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.
 

[EveLib] A .NET library for EveXML, CREST, EveCentral, and more

First post
Author
Icahmura Hasaki
Perkone
Caldari State
#181 - 2015-06-12 13:23:54 UTC  |  Edited by: Icahmura Hasaki
Its just very cumbersome to use in most relevant scenarios, it seems to be designed around some theoretic ideal instead of realistic use cases. The Auth mechanism was always intended for HTTP/browsers, as its using OAuth, which is fine. Theres a module for it in EveLib, EveAuth. You need to log in using your browser once to retrieve the authorization code, but the library will handle the rest from there, no redirects needed, just copy it from your browser and provide it to the Auth object.

edit: Speaking of crest, why is the refresh token blank/null now, I'm certain it wasn't before... Did I miss something ?

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#182 - 2015-06-12 13:25:56 UTC
I thought that in order to use it, you have to register an application with CCP and provide a URL call back address?
Icahmura Hasaki
Perkone
Caldari State
#183 - 2015-06-12 13:35:32 UTC  |  Edited by: Icahmura Hasaki
Register you application here https://developers.eveonline.com/
Set the callback to /
Go to
https://login.eveonline.com/oauth/authorize/?response_type=code&redirect_uri=/&client_id=YOUR-APP-ID-HERE&scope=publicData&state=devstate
and login. The URL in your browser will change, providing you with an auth code. Use that to obtain a refresh token, either through EveAuth or some HTTP client. Store the refresh token somewhere, it can be used indefinitely, and give that to EveAuth when you create a new object :)

edit: I changed the login URL, I forgot to set scope to publicData.

Developer of EveLib and EveAuthUtility

Icahmura Hasaki
Perkone
Caldari State
#184 - 2015-06-12 14:09:26 UTC
Im writing up a quick utility now to make it easier to get refresh tokens, give me a few minutes. Then you shouldn't have to use EveAuth, just run the tool, get your refreshtoken and provide that to EveCrest in EveLib.

Developer of EveLib and EveAuthUtility

Icahmura Hasaki
Perkone
Caldari State
#185 - 2015-06-12 15:00:11 UTC
Here's a small CLI to assist in obtaining the access- and refresh tokens. It's very rudimentary, but it should do the job. Just follow the instructions, and ask here if there's any issues.

https://github.com/ezet/evelib/releases/download/v1.0-EveAuthUtil/EveAuthUtility.rar

The source is on github as part of evelib, and it uses EveAuth for the actual authentication process :)

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#186 - 2015-06-12 15:09:53 UTC  |  Edited by: KillaGouge
I may be an idiot, but when I paste in the full url it tells me it is unable to locate the authentication code. Can I paste in the url, or does it need to be entered manually?

Edit: It looks like for some reason the URL in the browser after I login doesn't contain the &state text

Edit2: if I manually add &scope to the end of the url it works.
Icahmura Hasaki
Perkone
Caldari State
#187 - 2015-06-12 15:19:49 UTC
You are completely right, for now just add &state=whatever at the end of the url before pasting it. I'll fix it later :p

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#188 - 2015-06-12 15:22:32 UTC
when calling

EveCrest crest = new EveCrest("I know the refresh token goes here", encodedKey);

What is the encodedKey?

Thanks again for all your help. It is nice to know I can ask the basic questions.
Icahmura Hasaki
Perkone
Caldari State
#189 - 2015-06-12 15:26:00 UTC
It's the base64 encoded clientId + secretKey. Give me 5 minutes and I'll sort these things and upload a new version :)

Developer of EveLib and EveAuthUtility

Icahmura Hasaki
Perkone
Caldari State
#190 - 2015-06-12 15:36:28 UTC
KillaGouge
Imperial Shipment
Amarr Empire
#191 - 2015-06-12 15:43:16 UTC  |  Edited by: KillaGouge
Awesome man, that works great. I create a new EveCrest object and pass that in. I am able to get an alliance name back

Is this syntax right for looking up information on an item

var item = crest.GetRoot().Query(r => r.ItemTypes).Query(r => r.Single(a => a.Id == 18));

or is there a place where I can go to see all the crest syntax?

Thanks for all your help man.
Icahmura Hasaki
Perkone
Caldari State
#192 - 2015-06-12 16:04:47 UTC
Does it work? I honestly don't remember, its been like 8 months since I had a look at the CREST part. The CREST documentation pretty sparse, and the documentation I have is in the readme on github. At this point its still very much a work in progress, sorry. I'll see if have time to look at it again in the next few days, but I'll be leaving shortly so I don't have time to look at it right now What?

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#193 - 2015-06-12 16:18:48 UTC
Right now it just sort of hangs. I'll dig and see what I can find. The alliance query you give as an example works. So the crest auth is working.

Thanks for everything
KillaGouge
Imperial Shipment
Amarr Empire
#194 - 2015-06-22 18:33:02 UTC  |  Edited by: KillaGouge
I have a new stupid question.

I am trying to get the fitting of the last ship the character was in. This is what I have so far




Character character = ckey.Characters.Single(c => c.CharacterName == "KillaGouge");
var inventory = character.GetAssetList();           
var lastShip = character.GetCharacterInfo().Result.ShipTypeId;


I am not sure what I'd need to do to inventory to get all the instances of items with the same TypeId as lastShip

I thought it would be
inventory.Result.Items.Where(item => item.ItemId == lastShip);


but that doesn't return an object I can foeach through.

Anybody have an idea on how I can be less wrong?

Edit: Apparently I am an even bigger idiot than I thought, I used itemId rather than TypeId.
Icahmura Hasaki
Perkone
Caldari State
#195 - 2015-06-22 19:20:32 UTC  |  Edited by: Icahmura Hasaki
KillaGouge wrote:
I have a new stupid question.

I am trying to get the fitting of the last ship the character was in. This is what I have so far




Character character = ckey.Characters.Single(c => c.CharacterName == "KillaGouge");
var inventory = character.GetAssetList();           
var lastShip = character.GetCharacterInfo().Result.ShipTypeId;


I am not sure what I'd need to do to inventory to get all the instances of items with the same TypeId as lastShip

I thought it would be
inventory.Result.Items.Where(item => item.ItemId == lastShip);


but that doesn't return an object I can foeach through.

Anybody have an idea on how I can be less wrong?


The list is returned as a hierarchy of containers, ships, positions and such, so you would have to flatten the list or traverse the hierarchies. If you flatten it completely, you will lose information about what the ship contains. I think I wrote a function called Flatten for that, available on the Result object, or the Items list, cant remember exactly.

edit: check http://wiki.eve-id.net/APIv2_Char_AssetList_XML

You probably want to traverse the tree yourself, and if Im not mistaken you only have to go 2 levels deep, since ships cannot be contained in anything else. So you need to check every location, and then every item in that location.

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#196 - 2015-06-22 19:28:28 UTC  |  Edited by: KillaGouge

var lastShip = character.GetCharacterInfo().Result.ShipTypeId;
var lastShipContainer = inventory.Where(item => item.TypeId == lastShip);
foreach (var item in lastShipContainer)
{
    foreach (var subItem in item.Items)
    {
        resutlLabel.Text += GetItem(subItem.TypeId).Name;
    }
}


This works. I just need to do some testing for cases where the user has multiple of the same ship type.
Clyde en Marland
White Fang Militia
Fraternity.
#197 - 2015-06-23 08:47:18 UTC  |  Edited by: Clyde en Marland
I think you missed a bit from your post.

Also (seeing as I'm supposed to be pushing Linq for some reason at work), this line

inventory.Where(item => item.TypeId == character.GetCharacterInfo().Result.ShipTypeId).ToList().ForEach(subItem => resutlLabel.Text = string.Concat(resutlLabel.Text, GetItem(subItem.TypeId).Name));

could replace

var lastShip = character.GetCharacterInfo().Result.ShipTypeId;
var lastShipContainer = inventory.Where(item => item.TypeId == lastShip);
foreach (var item in lastShipContainer)
{
foreach (var subItem in item.Items)
{
resutlLabel.Text += GetItem(subItem.TypeId).Name;
}
}

The string.Concat method is more resource-usage friendly than += for putting multiple strings together, as += creates a new string in memory.
KillaGouge
Imperial Shipment
Amarr Empire
#198 - 2015-06-23 14:14:41 UTC

inventory.Where(item => item.TypeId == character.GetCharacterInfo().Result.ShipTypeId).ToList().ForEach(subItem => resutlLabel.Text = string.Concat(resutlLabel.Text, GetItem(subItem.TypeId).Name));


Produces this output

Golem


    var lastShip = character.GetCharacterInfo().Result.ShipTypeId;
    var lastShipContainer = inventory.Where(item => item.TypeId == lastShip);
    foreach (var item in lastShipContainer)
    {
         foreach (var subItem in item.Items)
         {
              var itemInfo = GetItem(subItem.TypeId);
              resutlLabel.Text += itemInfo.Name;
         }
    }


Produces this output, which is what I am looking for

Mobile Tractor Unit
Cruise Missile Launcher II
Bastion Module I
Salvager I
Caldari Navy Large Shield Booster
Pithum C-Type Adaptive Invulnerability Field
Adaptive Invulnerability Field II
Republic Fleet Target Painter
Large Micro Jump Drive
Caldari Navy Ballistic Control System
Large Warhead Flare Catalyst II
Caldari Navy Ballistic Control System
Large Warhead Flare Catalyst II
Salvager I
Republic Fleet Target Painter
Republic Fleet Target Painter
Caldari Navy Ballistic Control System
Caldari Navy Ballistic Control System
Salvager I
Hornet II
Hornet II
Hornet II
Hornet II
Cruise Missile Launcher II
Cruise Missile Launcher II
Cruise Missile Launcher II
Icahmura Hasaki
Perkone
Caldari State
#199 - 2015-06-23 14:41:07 UTC  |  Edited by: Icahmura Hasaki
Anyone have any good ideas for a way to pass parameters when querying crest resources? Such as the market orders, or items in a specific group. They want us to pass along the full crest uri of eg. a ItemType as the parameter, and I can't really think of any good way to do this...

Example: https://api-sisi.testeveonline.com/market/10000002/orders/buy/?type=https://api-sisi.testeveonline.com/types/587/

At the moment I there doesn't seem to be a way to navigate to this from the root? So I'll basically have to construct the URL client side, inserting the region ID and all, which seems to be completely the opposite for how they wanted crest to be used.. ?

Developer of EveLib and EveAuthUtility

KillaGouge
Imperial Shipment
Amarr Empire
#200 - 2015-06-23 14:50:25 UTC
couldn't you have a method that takes that information as parameters? So it would be GetMarketData(int regionId) and have overloaded constructors to get to the specifics a call would need?

Disclaimer, I am still new to programming