HTTP Library
I was wondering if there is any HTTP libraries made for AMX to do simple HTTP/REST/XML requests (i.e Posts). As i am unsure on how to establish a port as the Netlinx Help is not that helpful.
0
Comments
PROGRAM_NAME='TCPComm' DEFINE_CONSTANT INCLUDE 'SNAPI' DEFINE_VARIABLE CHAR strIpAddress[16] = '192.168.1.125'; INTEGER nIpPort = 80 ; INTEGER nIpConneted = 0; // 0 = disconnected, 1 = connected. CHAR strIpStack[50]; DEFINE_FUNCTION PopStack(){ IF(LENGTH_STRING(strIpStack)) SEND_STRING dvIP, strIpStack strIpStack = ''; } DEFINE_FUNCTION PushStack(CHAR sCmd[]){ strIpStack = sCmd; } DEFINE_FUNCTION ConnectIP(){ IP_CLIENT_OPEN(dvIp.PORT, strIpAddress, nIpPort, IP_TCP); // this is the main connection command } DEFINE_FUNCTION SendCommand(CHAR sCmd[]){ IF(nIpConneted) SEND_STRING dvIP, sCmd ELSE { PushStack(sCmd); ConnectIP(); } } DEFINE_EVENT //INSERT COMMANDS HERE DATA_EVENT[dvIP] { STRING: { } ONLINE :{ nIpConneted = 1; PopStack(); } OFFLINE:{ nIpConneted = 0; ConnectIp(); } ONERROR : { nIpConneted = 0; } }Oh, and you'll want to close the connection after you get a response, and open a new one for the next command, unless you want to mess with HTTP/1.1 connection handling, which I've never paid attention to.