Silithus
User avatar
Posts: 52
Likes: 45
Gnome Rogue 52 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

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.

Code: Select all


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.

Alterac Valley
User avatar
Discord:

Henhouse#1234


Bnet:

Henhouse#1695


Posts: 80
Likes: 58
Alliance Priest 80 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

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.

   Defuzed
Image
Warrior Protection
User avatar
Discord:

teebling#5444


Bnet:

Teeb#2674


Posts: 1149
Likes: 2159
525 posts
Orc
Warrior
Orc Warrior 525 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

Tillman32 wrote:
4 months ago
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.
Defuzed wrote:
4 months ago
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:
Henhouse wrote:
4 months ago
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:

   Defuzed
Alterac Valley
User avatar
Posts: 127
Likes: 271
Dwarf Paladin 126 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

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 ?!?

   teebling Sine
Image Image
User avatar
Posts: 2
Likes: 2
Horde 2 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

@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?

Hillsbrad Foothills
User avatar
Bnet:

Sine#21803


Posts: 5
Likes: 1
5 posts
Alliance
Alliance 5 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

Uncle Ganus McAnus wrote:
4 months ago
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 ?!?
Fear not McAnus, it is mere https://classic.wowhead.com/spell=7411. Although it might seem like some https://classic.wowhead.com/spell=18769 to a Paladin, I assure you it has more in common with the work of the Gnomes than any dark language of the North.

Winterspring
User avatar
Bnet:

HarTstaRx #2938


Posts: 110
Likes: 37
Troll Warrior 110 posts
4 months ago (Pre-release)
4 months ago (Pre-release)
 •  Unread

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

daisyKutter - Image Troll Image Protection Image Warrior
EU PvE - Pyrewood Village - Image Horde
Similar topics
to 'Help getting the Blizzard API working'
Posts ViewsLast post