View Single Post
Deathknife
Senior Member
Join Date: Aug 2014
Old 07-14-2016 , 13:39   Re: [ANY] SteamWorks
Reply With Quote #424

Quote:
Originally Posted by iGANGNAM View Post
Can I post https://forums.alliedmods.net/showthread.php?t=184604 JSON with this extension with HTTP Requests? JSON's may be longer than 512 or 1024 symbols... So I'm just wondering... Why does sourcemod even have limit of char anyway (facepalm)
This is what I use and it works, it probably isn't the best way or a good way at all, but it works fine. it doesn't format json with spaces etc to preserve characters.

PHP Code:
void SendRequest(Handle json) {
    
//json_dump
    
static char stringJson[16384];
    
stringJson[0] = '\0';                                 
    
//JSON To string
    
if(json != null)
        
json_dump(jsonstringJsonsizeof(stringJson), 0true);
    else
        
stringJson[0] = '\0';                                 
...
    
//Create handle
    
Handle request SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOSTurl);
    if(
request == INVALID_HANDLE) {
        
ThrowError("Couldn't create http request at url '%s'"url);
    }
    
//Set data
    
if(!SteamWorks_SetHTTPRequestContextValue(requesttypejson)) {
        
ThrowError("Couldn't create http request at url '%s'"url);
    }

    
//Set post data
    
if(!SteamWorks_SetHTTPRequestRawPostBody(request"application/json; charset=UTF-8"stringJsonstrlen(stringJson))) {
        
ThrowError("Couldn't create http request at url '%s'"url);
    }
    
    ...

    
//Send Reqquest
    
SteamWorks_SendHTTPRequest(request);

__________________

Last edited by Deathknife; 07-22-2016 at 23:37. Reason: https://forums.alliedmods.net/showpost.php?p=2437003&postcount=427
Deathknife is offline