This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazyHackGUT
AlliedModders Donor
Join Date: Feb 2016
Location: Izhevsk, Russia
Old 08-02-2021 , 14:26   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/06/06)
Reply With Quote #1

It is possible to send non-chunked request body? Sometimes for shared web-hostings it breaks everything, unfortunately.
__________________
My english is very bad. I am live in Russia. Learning english language - very hard task for me...
CrazyHackGUT is offline
Send a message via ICQ to CrazyHackGUT Send a message via Skype™ to CrazyHackGUT
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-24-2021 , 11:48   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/06/06)
Reply With Quote #2

Quote:
Originally Posted by CrazyHackGUT View Post
It is possible to send non-chunked request body? Sometimes for shared web-hostings it breaks everything, unfortunately.
Have you tried
PHP Code:
request.SetHeader("Transfer-Encoding"""); 
? I'm not sure if it will work, since it puts a space after the colon.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
mrdiega
Member
Join Date: Dec 2020
Old 10-04-2021 , 17:18   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)
Reply With Quote #3

can i use it with sv_hibernate_when_empty 1?
(plugin !stickers)
mrdiega is offline
leandro442
Member
Join Date: Sep 2013
Location: Portugal
Old 08-10-2022 , 14:11   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)
Reply With Quote #4

hello, I was trying to create a header through ripext on a test site but nothing happens I don't know why, has anyone created a header and did it work? do we have to give some permission or create code type in index.php? to work?
leandro442 is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 12-04-2021 , 15:48   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)
Reply With Quote #5

Hi, please add "GetDataType". Thanks <3
__________________
kratoss1812 is offline
Stewart Anubis
Junior Member
Join Date: Jul 2020
Old 01-25-2022 , 15:03   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)
Reply With Quote #6

Does anyone know how I can convert this "[[["Hola","hello",null,null,10]],null,"en",null,null,null,null,[]]" to "Hola" using #include <ripext> ?

Code:
Handle CreateRequest(char[] input, char[] target)
{
    
    Handle request = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, "http://translate.googleapis.com/translate_a/single");
    SteamWorks_SetHTTPRequestGetOrPostParameter(request, "client", "gtx");
    SteamWorks_SetHTTPRequestGetOrPostParameter(request, "dt", "t");    
    SteamWorks_SetHTTPRequestGetOrPostParameter(request, "sl", "auto");//from en default, so you might wanna add this param too to modify.
    SteamWorks_SetHTTPRequestGetOrPostParameter(request, "tl", target);//to desired.. target language
    SteamWorks_SetHTTPRequestGetOrPostParameter(request, "q", input);//input text

    //final url would be something like this  https://translate.googleapis.com/tra...&tl=es&q=hello
    //response example [[["Hola","hello",null,null,10]],null,"en",null,null,null,null,[]]  so we need to parse json on Callback_OnHTTPResponse >  JSON.parse(response)[0][0][0] = Hola
    
    Handle datapack = CreateDataPack();
    WritePackString(datapack, target);
    WritePackString(datapack, input);

    
    SteamWorks_SetHTTPRequestContextValue(request, datapack);
    SteamWorks_SetHTTPCallbacks(request, Callback_OnHTTPResponse);
    return request;
}

public int Callback_OnHTTPResponse(Handle request, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, Handle datapack)
{
	if (!bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
	{	  
		CloseHandle(datapack);		
		return;
	}

	int iBufferSize;
	SteamWorks_GetHTTPResponseBodySize(request, iBufferSize);

	char[] result = new char[iBufferSize];
	SteamWorks_GetHTTPResponseBodyData(request, result, iBufferSize);
	delete request;
	
	char target[3], input[255];
	ResetPack(datapack);
	ReadPackString(datapack, target, 3);
	ReadPackString(datapack, input, 255);
	CloseHandle(datapack);

	PrintToServer(result); // = [[["Hola","hello",null,null,10]],null,"en",null,null,null,null,[]]
}

Last edited by Stewart Anubis; 01-25-2022 at 15:09.
Stewart Anubis is offline
foxhound27
AlliedModders Donor
Join Date: Sep 2019
Location: Argentina
Old 03-21-2023 , 15:03   Re: REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)
Reply With Quote #7

amazing, thx
foxhound27 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 20:05.


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