Created
June 30, 2012 00:42
-
-
Save tim-smart/3021609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local http = require('http') | |
local qs = require('querystring') | |
local json = require('json') | |
local table = require('table') | |
local headers = | |
{ ['Accept'] = 'application/json' | |
, ['Content-Length'] = 0 | |
} | |
local body = qs.stringify( | |
{ user = 'rj' | |
, api_key = 'b25b959554ed76058ac220b7b2e0a026' | |
, method = 'user.getRecentTracks' | |
, format = 'json' | |
} | |
) | |
local request = http.request( | |
{ headers = headers | |
, path = table.concat({ '/2.0/?', body }) | |
, host = 'ws.audioscrobbler.com' | |
, method = 'GET' | |
} | |
) | |
request:on('response', function (res) | |
local buf = {} | |
res:on('data', function (chunk) | |
buf[#buf + 1] = chunk | |
end) | |
res:on('end', function () | |
p('end event emitted') | |
end) | |
end) | |
request:done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment