Raised This Month: $51 Target: $400
 12% 

Send POST Params and retrieve JSON


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gh0$t
Senior Member
Join Date: Mar 2010
Location: Germany at 127.0.0.1
Old 04-23-2012 , 04:44   Send POST Params and retrieve JSON
Reply With Quote #1

Hello!
I want to send POST-Parameters to a webAPI that was written by me. I think i should use the socket extension:
http://forums.alliedmods.net/showthread.php?t=67640
but i don't know how can i realize this. The return of the API is a JSON-String, how can i parse this in SourcePAWN? And how can i send POST-Params?
Thanks for help.
__________________
Gh0$t is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 04-23-2012 , 06:10   Re: Send POST Params and retrieve JSON
Reply With Quote #2

You'd need to put your own POST request together. I'd recommend using the cURL extension.

There is no easy way to parse json in sourcepawn. You should use a simpler serialisation to push data to your gameserver.

__________________
Peace-Maker is offline
Gh0$t
Senior Member
Join Date: Mar 2010
Location: Germany at 127.0.0.1
Old 04-23-2012 , 06:13   Re: Send POST Params and retrieve JSON
Reply With Quote #3

Quote:
Originally Posted by Peace-Maker View Post
You should use a simpler serialisation to push data to your gameserver.
What do you mean with this?
Which serialisation should i use?
__________________
Gh0$t is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 04-23-2012 , 06:51   Re: Send POST Params and retrieve JSON
Reply With Quote #4

Imagine your own little format, like seperating infos by linebreaks or a "|" char or something easy like that.
__________________
Peace-Maker is offline
Gh0$t
Senior Member
Join Date: Mar 2010
Location: Germany at 127.0.0.1
Old 04-23-2012 , 07:01   Re: Send POST Params and retrieve JSON
Reply With Quote #5

Ah okay that do you mean
Thank you!
__________________
Gh0$t is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 04-23-2012 , 09:37   Re: Send POST Params and retrieve JSON
Reply With Quote #6

Writing a PHP script to return KeyValues isn't difficult at all.
__________________
Dr. McKay is offline
Reply



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 08:08.


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