Quote:
Originally Posted by iGANGNAM
|
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(json, stringJson, sizeof(stringJson), 0, true);
else
stringJson[0] = '\0';
...
//Create handle
Handle request = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, url);
if(request == INVALID_HANDLE) {
ThrowError("Couldn't create http request at url '%s'", url);
}
//Set data
if(!SteamWorks_SetHTTPRequestContextValue(request, type, json)) {
ThrowError("Couldn't create http request at url '%s'", url);
}
//Set post data
if(!SteamWorks_SetHTTPRequestRawPostBody(request, "application/json; charset=UTF-8", stringJson, strlen(stringJson))) {
ThrowError("Couldn't create http request at url '%s'", url);
}
...
//Send Reqquest
SteamWorks_SendHTTPRequest(request);
}
__________________