I'm having trouble with sockets (go figure, lol.)
Here is the code I have so far:
alias bf_sock {
sockopen bfsock
http://api.bfbcs.com 80
}
on *:sockopen:bfsock: {
echo -s Socket Opened Successfully.
sockwrite -n bfsock GET /api/360?players=IllogicTC&fields=all HTTP/1.1
sockwrite -n bfsock Host:
http://api.bfbcs.com $crlf $+ $crlf
}
on *:sockread:bfsock: {
if ($sockerr) {
echo -s Socket Error. Halting...
HALT
}
echo -s Socket Read Successfully.
var %bfsocktxt
sockread -f %bfsocktxt
echo -s RESULT: %bfsocktxt
sockclose bfsock
echo -s Socket Closed.
}
The echos are in there just for debug purposes, my goal is to be able to retrieve my BFBC2 stats from bfbcs.com's JSON API, but I keep getting:
RESULT: 400 HTTP/1.1 Bad Request
Where on Earth am I going wrong here!? As for the rest, if I can get the information into a variable I can take care of that easily, but this is my first real attempt on sockets