Raised This Month: $77 Target: $400
 19% 

REST in Pawn - Communicate with JSON REST APIs


Post New Thread Reply   
 
Thread Tools Display Modes
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 07-27-2017 , 13:24   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #11

Quote:
Originally Posted by ezio_auditore View Post
You can also add a function that generates the Authorization header...
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 View Post
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.
__________________
DJ Tsunami is offline
jdlovins
Junior Member
Join Date: Sep 2015
Old 07-27-2017 , 14:49   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #12

Quote:
Originally Posted by DJ Tsunami View Post
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.
jdlovins is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-27-2017 , 15:29   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #13

Quote:
Originally Posted by jdlovins View Post
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
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread]

Last edited by DarkDeviL; 07-27-2017 at 15:30.
DarkDeviL is offline
jdlovins
Junior Member
Join Date: Sep 2015
Old 07-27-2017 , 16:39   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #14

Quote:
Originally Posted by arne1288 View Post
"/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
jdlovins is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 07-27-2017 , 16:56   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #15

Looks like there's a curl_easy_escape(), so shouldn't be that hard.
__________________
DJ Tsunami is offline
jdlovins
Junior Member
Join Date: Sep 2015
Old 07-27-2017 , 17:57   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #16

Quote:
Originally Posted by DJ Tsunami View Post
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 is offline
jdlovins
Junior Member
Join Date: Sep 2015
Old 07-28-2017 , 22:37   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #17

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

Last edited by jdlovins; 07-28-2017 at 23:18.
jdlovins is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 07-29-2017 , 08:09   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #18

Any chance of functions to iterate through objects and arrays?
__________________
Not Taking Commissions | My [Dev] Website
Drixevel is offline
Deathknife
Senior Member
Join Date: Aug 2014
Old 07-29-2017 , 08:52   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #19

Quote:
Originally Posted by Drixevel View Post
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();

__________________
Deathknife is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Old 07-29-2017 , 11:22   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #20

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 View Post
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.
__________________

Last edited by DJ Tsunami; 07-29-2017 at 12:20.
DJ Tsunami is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:55.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode