AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22) (https://forums.alliedmods.net/showthread.php?t=298024)

DJ Tsunami 07-27-2017 13:24

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by ezio_auditore (Post 2536977)
You can also add a function that generates the Authorization header... :D

Great idea, but I would need to add hashing to this extension, which would make it more bloated. I'll think about it.

Quote:

Originally Posted by jdlovins (Post 2538125)
I guess this takes care of the JSON response and the actual response handles?

Correct, you don't have to worry about cleaning up response and response.Data.

jdlovins 07-27-2017 14:49

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by DJ Tsunami (Post 2538143)
Great idea, but I would need to add hashing to this extension, which would make it more bloated. I'll think about it.


Correct, you don't have to worry about cleaning up response and response.Data.


Awesome. Something that would be very useful is a URL encode function. For example if you call an API with parameters such as

/items?type=5&name=i have spaces

it will error out on the API end because of the spaces. Not sure how easy that is to solve really.

DarkDeviL 07-27-2017 15:29

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by jdlovins (Post 2538154)
Awesome. Something that would be very useful is a URL encode function. For example if you call an API with parameters such as

/items?type=5&name=i have spaces

it will error out on the API end because of the spaces. Not sure how easy that is to solve really.

"/items?type=5&name=i+have+spaces"

As this thing seems to be aimed at developers making their own things, I assume you're developing your own stuff that uses this thing, which means you could (remember code attribution!) "copy" this one:

From Dynamic MOTD by @psychonic:

UrlEncodeString

jdlovins 07-27-2017 16:39

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by arne1288 (Post 2538164)
"/items?type=5&name=i+have+spaces"

As this thing seems to be aimed at developers making their own things, I assume you're developing your own stuff that uses this thing, which means you could (remember code attribution!) "copy" this one:

From Dynamic MOTD by @psychonic:

UrlEncodeString


Correct, making an API and a plugin to use it. Hmm yeah i guess this would solve most things. Would be maybe nice to bake it into the extension since its focused around making web calls :)

DJ Tsunami 07-27-2017 16:56

Re: REST in Pawn - HTTP and JSON methodmaps
 
Looks like there's a curl_easy_escape(), so shouldn't be that hard.

jdlovins 07-27-2017 17:57

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by DJ Tsunami (Post 2538186)
Looks like there's a curl_easy_escape(), so shouldn't be that hard.

Oh hey there is. That would be pretty awesome if you exposed it :)

jdlovins 07-28-2017 22:37

Re: REST in Pawn - HTTP and JSON methodmaps
 
Sorry for the double post but...

I have a bug and i dont really even know how to describe it in words easily since I cant make a test plugin to replicate it but its definitely not working in the plugin i want it to.

Could i add you on steam DJ Tsunami?

Thanks

Drixevel 07-29-2017 08:09

Re: REST in Pawn - HTTP and JSON methodmaps
 
Any chance of functions to iterate through objects and arrays?

Deathknife 07-29-2017 08:52

Re: REST in Pawn - HTTP and JSON methodmaps
 
Quote:

Originally Posted by Drixevel (Post 2538512)
Any chance of functions to iterate through objects and arrays?

You can already iterate through arrays. Although objects would be nice. smjansson extension allows you to.

PHP Code:

property int Length {
        public 
native get();



DJ Tsunami 07-29-2017 11:22

Re: REST in Pawn - HTTP and JSON methodmaps
 
I intentionally left out object iteration to keep the code simple. Besides, when you're talking to an API you should know which fields are returned. If you're not talking to an API, I believe StringMap should suffice.

Quote:

Originally Posted by jdlovins (Post 2538456)
Could i add you on steam DJ Tsunami?

I'm never on Steam anymore, but I'll try to be on IRC in the coming days. You can also create an issue on GitHub with screenshots and what not.


All times are GMT -4. The time now is 05:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.