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.
 

Script for checking API key access mask

Author
Tirestun
Caldari Provisions
Caldari State
#1 - 2012-05-15 19:36:39 UTC
Hey all,

I'm a bit weak on JavaScript, so my apologies there, I'll try and muscle through the description of what I'm looking for, but bear with me here.

I need a script that will check a given API ID and Vcode's access mask, and if it returns a 'false' boolean value it won't allow them to hit the 'submit' button when registering. Really, I just need the chunk of code, or at least a brief explanation on how to pull that data via javascript and I should be able to figure the rest out myself.

If you've got a better solution, though, I'd love to hear it.


Many thanks;
.tirestun
Osku Rei
Pixel 6
#2 - 2012-05-16 09:13:10 UTC  |  Edited by: Osku Rei
frontend > ajax > backend > eve api.

So in your frontend (html page) do a Javascript ajax call to your backend (like a php file), this file does the API request and echos back back the xml response from the API; the ajax call then picks up the response and does stuff with it. Alternatively the php file could do the work/manipulate the xml and just return stuff that you need, in json/html for example.

I might be able to write up a small example later today.

Hope this helps. o/

P.s Your Javascript has to call your backend which then calls the API because Javascript doesn't allow Cross-domain-requests (same origin policy)

Next generation of lottery tracker coming soon! http://evelotterytracker.com/

Please like my post if it has helped you :)

Tirestun
Caldari Provisions
Caldari State
#3 - 2012-05-16 13:30:54 UTC
It's a start, at least I know what I'll need to learn.

Thanks, mate.
Khorkrak
KarmaFleet
Goonswarm Federation
#4 - 2012-05-17 02:37:57 UTC  |  Edited by: Khorkrak
It doesn't appear that fetching a url from some other site from within javascript is allowed due to XSS prevention: Can't Fetch a URL

Unfortunately you need to do so to get the API Key mask so that means you'll most likely have to go with AJAX and have your server code call the EVE API. Info on the EVE API method you need to call: API Key InfoThen simply parse the returned XML for the mask server side and return the value to your javascript. For example in Python with the given xml response string:

Get Access Mask

Developer of http://www.decloaked.com and http://sourceforge.net/projects/pykb/

Osku Rei
Pixel 6
#5 - 2012-05-17 08:24:01 UTC  |  Edited by: Osku Rei
Tirestun wrote:
It's a start, at least I know what I'll need to learn.

Thanks, mate.



Here's a very basic example:

HTML / Javascript (you'll need jQuery): http://pastebin.com/NVuMaSzt

PHP: http://pastebin.com/NDZNP2a6

I would recommend doing a simple validation check such as this on the server side and then returning true/false to the front end (which would then be used to enable/disable the button), this will reduce your code and keep things centralised.

Hope that helps :)

*Edit*

Running example Here

Next generation of lottery tracker coming soon! http://evelotterytracker.com/

Please like my post if it has helped you :)

Tirestun
Caldari Provisions
Caldari State
#6 - 2012-05-17 14:14:43 UTC
Good God, Osku, thank you!

I'll get to implementing this on the test side to make sure everything is kosher before going live.
Osku Rei
Pixel 6
#7 - 2012-05-17 15:28:30 UTC
Tirestun wrote:
Good God, Osku, thank you!

I'll get to implementing this on the test side to make sure everything is kosher before going live.


:) no problem, give me a shout if you need help.

Next generation of lottery tracker coming soon! http://evelotterytracker.com/

Please like my post if it has helped you :)