Hello,
Been awhile since I've been around here, but just came across a new API I was waiting for to come out, and have been trying to figure out implementation into IRC script.
Basically just simple GET/POST requests. I have everything working correctly, the requests are successful, but I can't seem to get any needed information.
This is the code to GET information, API pertains to points for being in the server gained per minute.
var %sw sockwrite -n points
%sw GET /1/fans/aeonpsych/points HTTP/1.1
%sw x-api-key: <api-key-removed>
%sw Content-Type: application/x-www-form-urlencoded
%sw Accept: application/json
%sw Host: <host-removed>:443
%sw Connection: close
%sw $crlf
When I use a web based request for the api call, the response is:
HTTP/1.1 200 OK
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-api-key
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Thu, 12 Jan 2017 09:00:45 GMT
Server: nginx/1.4.6 (Ubuntu)
X-Content-Type-Options: nosniff
Content-Length: 108
Connection: Close
{"loyalty":{"fan":"aeon","total_points":64,"current_points":64,"updated_at":"2017-01-12T09:00:00.000Z"}}
but when I make the request within irc client, the response is only the headers of the response (not any of the body), and I can't get the points data from such:
HTTP/1.1 200 OK
Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,x-api-key
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Thu, 12 Jan 2017 09:57:35 GMT
Server: nginx/1.4.6 (Ubuntu)
X-Content-Type-Options: nosniff
Content-Length: 115
Connection: Close
The POST request I use to add/subtract points works from both within the irc client and web client. The amount:3 is the total to add or subtract):
var %sw sockwrite -n addpoints
%sw POST /1/fans/aeon/points/bonus HTTP/1.1
%sw x-api-key: <api-key-removed>
%sw Content-Length: 14
%sw Content-Type: application/x-www-form-urlencoded
%sw Accept: application/json
%sw Host: <host-removed>:443
%sw Connection: close
%sw $crlf
%sw {"amount": 3}
The assistance I am looking for is how can I get the points data from the socket/request? It comes out great when I make the call from a web client, but not from within irc.