valrus / undertale-dialog-generator

A WIP Elm project for generating Undertale dialog boxes.
http://thehotvoice.mccowan.space/
Other
24 stars 5 forks source link

Open API #68

Closed henry232323 closed 7 years ago

henry232323 commented 7 years ago

Is it possible to get an open use API for this? Without reverse engineering it of course, I'd like to be able to get these from a quick get request on the API.

valrus commented 7 years ago

There's really only one endpoint that matters and that's the /submit URL.

My poor website is apparently being hit too hard at the moment for me to test this, but here's an example using the Python requests module:

r = requests.get('http://thehotvoice.mccowan.space/',
                 params={'text': 'Hi!\nThis is an API call!',
                         'moodImg': ['images/sprites/Papyrus/0.png']})

That request generates the following URL:

http://thehotvoice.mccowan.space/?text=Hi%21%0AThis+is+an+API+call%21&moodI
mg=images%2Fsprites%2FPapyrus%2F0.png

so if you're using something other than the Python requests module you just need to make a URL like that. You'll get back a b64-encoded PNG file.

It's not designed to be accessed like this so if you do it wrong the error message might not be very helpful. In particular, the text you pass in is split into groups of 3 lines, each of which groups goes into a dialog box. You need to pass one moodImg param for each box. And the moodImg arguments are just numbers (the path construction should be pretty obvious) so you need to figure out what number corresponds to which picture. (You can just look in here to find that out!)

That's about it. LMK if that's not enough to go on.

henry232323 commented 7 years ago

Awesome thanks!

henry232323 commented 7 years ago

Hmm you'll probably get the same result if you use your link, but using yours or other requests, it just directs me to the http://thehotvoice.mccowan.space/ page, and it seems trying anything on the /submit endpoint, it 404's

valrus commented 7 years ago

Alright, I got it working. The working example URL that worked for me:

http://ianmccowan.nfshost.com/undertale/submit?text=Hi%21%0AThis+is+an+API+call%21&moodImg=%2Fundertale%2Fstatic%2Fimages%2Fsprites%2FPapyrus%2F0.png

For some reason it doesn't like you to do it with the thehotvoice URL; I guess the redirect I'm using with my domain doesn't play well with requests.

valrus commented 7 years ago

Oh, actually, this works too:

http://thehotvoice.mccowan.space/undertale/submit?text=Hi%21%0AThis+is+an+API+call%21&moodImg=%2Fundertale%2Fstatic%2Fimages%2Fsprites%2FPapyrus%2F0.png

Note that I had to add a couple extra path components to the sprite image as well.

henry232323 commented 7 years ago

Oh there we go awesome, thanks!

valrus commented 7 years ago

No problem. Closing this now.

henry232323 commented 7 years ago

Oh just to let you know, in testing, I found that http://ianmccowan.nfshost.com yielded the actual result http://thehotvoice.mccowan.space popped it in an <iframe>

valrus commented 7 years ago

What about http://thehotvoice.mccowan.space/undertale ?

henry232323 commented 7 years ago

On both I was using /undertale/submit

henry232323 commented 7 years ago

Did you say you were forewarning the domain instead of DNS?

henry232323 commented 7 years ago

Forewarding*