Help getting the Bl...
 
Notifications
Clear all

Help getting the Blizzard API working

30 Posts
9 Users
0 Reactions
15.7 K Views
(@teebling)
Posts: 1611
Noble Member
Topic starter
 

<snip>

I couldn't understand how JavaScript was a backend language now... but well... it is, lol. I really dislike it, but some love it.

OMG right, this totally makes sense now. So basically some nerds are like... compiling code... with javascript, which to me and you is what we would use to make a box fade in and out of the screen 5 years ago. Okay, wow things change pretty damned fast.
However, it seems that that may go a bit outside what you're familiar with? If you'd like, despite me being a bit busy, I totally don't mind building this for you. I am a backend developer that has a ton of experience building APIs and making integration with 3rd party ones. I would enjoy doing this, and have been looking for an excuse to work with the Blizzard API.

Well, wow, that would be awesome to have you working on it if it's something you'd enjoy doing! Don't feel like its a commitment or anything though Hen - I mean all I'm trying to do right now anyway is grab realm stats for the 'Realms' section of the website. I think with Anders' script and the two ajax requests I can make that happen now. But yes it would be very cool to have an extended range of features for the future! Why not! :biggrin:

 
Posted : 21/04/2019 2:45 pm
(@teebling)
Posts: 1611
Noble Member
Topic starter
 

Awesome, as @Henhouse said if you want to get more stuff in the future you will need something quite a bit more robust, public api.barrens.chat github??!?! :razz:

I don't know what that means but it sounds cool :mrgreen:

 
Posted : 21/04/2019 2:46 pm
(@henhouse)
Posts: 78
Trusted Member
 

Awesome, as @Henhouse said if you want to get more stuff in the future you will need something quite a bit more robust, public api.barrens.chat github??!?! :razz:

Hehe, maybe like:
GET https://api.barrens.chat/honorable-kills?playerName=Uncle Ganus McAnus

Response: 500 Internal Server Error - error: integer overflow
Only nerds will get this :sad:

Uncle Ganus McAnus

 
Posted : 21/04/2019 2:51 pm
(@henhouse)
Posts: 78
Trusted Member
 

Well, wow, that would be awesome to have you working on it if it's something you'd enjoy doing! Don't feel like its a commitment or anything though Hen - I mean all I'm trying to do right now anyway is grab realm stats for the 'Realms' section of the website. I think with Anders' script and the two ajax requests I can make that happen now. But yes it would be very cool to have an extended range of features for the future! Why not!
First iteration to display just realm info shouldn't be very hard. I could probably take a look tomorrow if you don't figure anything out with it in PHP. Going forward this is likely the better way so you don't put more pressure on the forum code by making it have to perform the work of an API.

Do you have a GitHub/GitLab?

 
Posted : 21/04/2019 2:57 pm
(@teebling)
Posts: 1611
Noble Member
Topic starter
 

Well, wow, that would be awesome to have you working on it if it's something you'd enjoy doing! Don't feel like its a commitment or anything though Hen - I mean all I'm trying to do right now anyway is grab realm stats for the 'Realms' section of the website. I think with Anders' script and the two ajax requests I can make that happen now. But yes it would be very cool to have an extended range of features for the future! Why not!
First iteration to display just realm info shouldn't be very hard. I could probably take a look tomorrow if you don't figure anything out with it in PHP. Going forward this is likely the better way so you don't put more pressure on the forum code by making it have to perform the work of an API.

Do you have a GitHub/GitLab?

Alright great! I'll give the PHP thing a go anyway for my own pride's sake :lol: but if you think it'd be better to take that load away from the forum software then I'm with you on this :smile:

I have an account on github yeah - teebling. Not sure if that's what you mean Hen.

 
Posted : 21/04/2019 2:58 pm
(@henhouse)
Posts: 78
Trusted Member
 

Alright great! I'll give the PHP thing a go anyway for my own pride's sake but if you think it'd be better to take that load away from the forum software then I'm with you on this

I have an account on github yeah - teebling. Not sure if that's what you mean Hen.
Yep, great. If I do anything tomorrow I'll setup a private repository and add you to it so you can see what I do.

 
Posted : 21/04/2019 3:04 pm
(@teebling)
Posts: 1611
Noble Member
Topic starter
 

Sweet - maybe get Anders involved as well if he's keen :smile:

 
Posted : 21/04/2019 3:04 pm
(@anders)
Posts: 6
Active Member
 

Sure if Henhouse wants another set of eyeballs :smile:, not sure how much time I will have but I am happy to help when I can. Github is Komodo123

 
Posted : 21/04/2019 3:16 pm
(@tillman32)
Posts: 2
New Member
 

Hello teebling,

I'm the author of the "actual good doc" in AngularJS. First off thanks for reading my stuff, second off - I read through this and have a simple solution.

Yes, the Blizzard API did move to the OAuth2 authorization flow. My post is out of date but since you shouldn't have your client secrets visible in the web (doesn't belong in this layer), I didn't really bother creating anything for it in AngularJS.

As others have mentioned, you could write something separate and that does have its advantages. There are a lot of popular languages out there, but since you're on a web host you're limited to what is installed. I'm not sure what is involved with creating a phpBB addon, but if you know php that might be a good route.

Good news is every linux box comes with bash and python - both could be used in a simple way to achieve what you want. Using a simple bash script, you could use that very curl request (with your client id and secret "hidden" from the web on your server) and save the json result to a file (let's say token.json).

From there you have a few options:

Option 1: Extend the bash/python script to parse the token.json for your token, and make the second request for the realm data. Once again you'd save that output on the server as your "cached" version (realm.json). You'd create a simple cron job to do this every 15 minutes. If you saved this realm.json file in a publically accessible place (aka wwwroot/data/realm.json), you could retrieve it from jQuery just like you wanted via a local url (barens.chat/data/realm.json for example). You could still make this request on page load, but it would be loading the local file so no worries about your rate limit. Done.

Option 2: Parse the token.json from phpBB/php, use the token to make the second request for realm data, build the page... done (lots of "hidden steps" here)

Make sense?

Here is a real simple bash script that could be used for getting the token. If you'd like help making the second request in a language native to your hosting platform (bash/python), or need advice on another route - I can help!

#!/bin/bash

TOKEN_ENDPOINT="https://us.battle.net/oauth/token"
TOKEN_FILENAME="token.json"

CLIENT_ID="<id here>"
CLIENT_SECRET="<secret here>"

curl -u $CLIENT_ID:$CLIENT_SECRET -d grant_type=client_credentials $TOKEN_ENDPOINT > $TOKEN_FILENAME

 
Posted : 21/04/2019 9:50 pm
(@defuzed)
Posts: 52
Trusted Member
 

You can easily do this in vanilla js, if I read it correct all you need is a fetch() and abit of code to type out ur fetched data.

I am writing this on my phone so there may be a mistake but I'll try to look carefully so there won't be any.


let maldivh;

function grapData(){
fetch("insert your API route here")
.then((response) => {
return response.json();
})
.then((data) => {
maldivh = data;
updater();
});
}

function updater(){
document.querySelector("#test").innerHTML = maldivh;

// Since the maldivh variable is now an object you will have to navigate around in it to get the specific data. Example: maldivh.realm to print the realm information etc

This is made rather quick so if you want a more in depth version or simply a better explanation just say so. Hope it answers your question in a simple manner.

EDIT: Just read the full post (which I probably should have started with) and can see your question was abit more complicated, I can help when I get home on my PC.
Good thing though I am 99% sure I can fix your problems when I get home.

 
Posted : 22/04/2019 1:22 am
(@henhouse)
Posts: 78
Trusted Member
 

I think there's a bit of concern with doing it in JS because anyone would be able to see his private API keys making the requests.

 
Posted : 22/04/2019 2:07 am
(@teebling)
Posts: 1611
Noble Member
Topic starter
 

I'm the author of the "actual good doc" in AngularJS...

<snip>

Good news is every linux box comes with bash and python - both could be used in a simple way to achieve what you want. Using a simple bash script, you could use that very curl request (with your client id and secret "hidden" from the web on your server) and save the json result to a file (let's say token.json).

From there you have a few options:

Option 1: Extend the bash/python script to parse the token.json for your token, and make the second request for the realm data. Once again you'd save that output on the server as your "cached" version (realm.json). You'd create a simple cron job to do this every 15 minutes. If you saved this realm.json file in a publically accessible place (aka wwwroot/data/realm.json), you could retrieve it from jQuery just like you wanted via a local url (barens.chat/data/realm.json for example). You could still make this request on page load, but it would be loading the local file so no worries about your rate limit. Done.

Option 2: Parse the token.json from phpBB/php, use the token to make the second request for realm data, build the page... done (lots of "hidden steps" here)

Make sense?

Hey Tillman32, it's a small world huh? :smile:

That totally makes sense but is impractical for me as I travel a lot and can't just leave a linux box running bash/curl/py scripts with cron jobs as you describe - I spend a month at sea and then return for a month, all year round so the realm stats wouldn't work for half the year. That certainly is a very simple and elegant solution however and if I were a 9-5er that would work out well I think.
EDIT: Just read the full post (which I probably should have started with) and can see your question was abit more complicated, I can help when I get home on my PC.

Yeah pretty much what hen said:
I think there's a bit of concern with doing it in JS because anyone would be able to see his private API keys making the requests.

I think the PHP route or whatever Henhouse thinks is the most extendable/attractive option would be best. Now that JS out of the question due to security stuff I suppose my 'next-best' language is PHP. I say next best but more like 'least worst' :lol:

 
Posted : 22/04/2019 2:37 am
(@uncle-ganus-mcanus)
Posts: 176
Estimable Member
 

By the https://classic.wowhead.com/item=10047/simple-kilt of https://classic.wowhead.com/npc=8503/gibblewilt , I say ! What is this gibberish small talk all about ?!? I thought Gorloc Gibberers existed only in Northrend ?!?

 
Posted : 22/04/2019 3:24 am
(@tillman32)
Posts: 2
New Member
 

teebling I assumed you'd be running it off the same host that runs your phpBB form 24/7. Or at least, I assume that doesn't go down when you're out at sea, right?

 
Posted : 22/04/2019 3:24 pm
(@daisykutter)
Posts: 146
Estimable Member
 

Ey there teebling,
Anders & Tillman32 are the way to go! Just write a wrapper for the authentication call and hide your secret

 
Posted : 23/04/2019 4:28 am
Page 2 / 2
Share: