View Single Post
CrazyHackGUT
AlliedModders Donor
Join Date: Feb 2016
Location: Izhevsk, Russia
Old 02-09-2018 , 15:46   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #46

So, i forked this extension 31 oct. 2017, and made small changes.
  • Fixed segfault
  • Added timeout connection and waiting response, "Follow location" settings in HTTPClient methodmap.
  • IChangeableForward removed, now extension uses IPluginFunction.
  • Callback modified: added ability for receive error string.
    Code:
    public void OnRequestFinished(HTTPResponse hResponse, any iData, const char[] szError) {
        if (szError[0] != 0) {
            LogError("Error received when processing request: %s", szError);
            return;
        }
    
        // handle response...
    }
    But you can still use this old function prototype, without receiving error message:
    Code:
    public void OnRequestFinished(HTTPResponse hResponse, any iData) {
        // handle response...
    }
    But in this case, you should add check:
    Code:
    if (hResponse != null)

You can see source code here. Download binaries here.
__________________
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