you need to fork the library and rewrite the httpPost()
function to add the headers elements you need:
#define REST_APP_ID "gmOpYot0OhWGnkMojjZv9KYUHMySCSeTGyyplArZ"
#defnie REST_API_KEY "XQMA4Wd3SQdOsxudtKz5OdbPaVN3YE9aOKx0VSh2"
int InetGSM::parsePOST(const char* path, const char* parameters, char* result, int resultlength)
{
const char* server = "https://api.parse.com";
int port = 443;
char itoaBuffer[8];
int num_char;
if (!gsm.connectTCP(server, port)){
return 0;
}
strcpy(_buffer,"POST ");
strcat(_buffer,path);
strcat(_buffer," HTTP/1.0\nHost: ");
strcat(_buffer,);
strcat(_buffer,"\nX-Parse-Application-Id: ");
strcat(_buffer,REST_APP_ID);
strcat(_buffer,"\nX-Parse-REST-API-Key: ");
strcat(_buffer,REST_API_KEY);
strcat(_buffer,"\nContent-Type: application/json");
strcat(_buffer,"\nContent-Length: ");
itoa(strlen(parameters),itoaBuffer,10);
strcat(_buffer,itoaBuffer);
strcat(_buffer,"\n\n");
strcat(_buffer,parameters);
strcat(_buffer,"\n\n");
gsm.SimpleWrite(_buffer);
gsm.disconnectTCP();
return 1;
}
you may want to pass REST_APP_ID
and REST_API_KEY
as parameters as well. And don't forget to add the prototype of your
function in the header as well. To then use your function, you can call it as follows:
inet.parsePOST("/1/classes/PercentFull", "{\"Level\":90, \"Temp\":25}", msg, 50);
be careful that per default _buffer
size is only 50
characters. You may want to increase its size. You may as well want
to put all strings in flash to save some precious memory F("my string")
for the win!