Skip to content

Instantly share code, notes, and snippets.

View mikekatz's full-sized avatar

Michael Katz mikekatz

  • New York, NY
  • 15:11 (UTC -04:00)
View GitHub Profile
@mikekatz
mikekatz / ReadLuaTableFromKinvey.lua
Created June 8, 2012 15:51
Save Lua Table To Kinvey - blog exmaple 2 - read
-- GET back the object to verify that we saved it
response = {}
save = ltn12.sink.table(response)
id = objAsTable["_id"] -- get the _id field from the object table
url = "https://baas.kinvey.com/appdata/KINVEY_APP_ID/testObjects/" .. id
h = {Authorization = "Basic " .. (mime.b64("KINVEY_APP_ID:KINVEY_APP_SECRET")), ["Content-Type"] = "application/json" }
ok, code, headers = http.request{url = url, headers = h, sink = save, redirect = true, method = "GET"}
@mikekatz
mikekatz / SaveLuaTableToKinvey.lua
Created June 8, 2012 15:50
Save Lua Table to Kinvey - blog example
-- load required modules
http = require("socket.http") --luasocket
ltn12 = require("ltn12")
mime = require("mime")
io = require("io")
json = require("json") -- luajson
-- Create a Lua table to represent our entity to save
--- This is from our doc REST example: http://docs.kinvey.com/rest-appdata.html
jamesBond = { ["firstName"] = "James", ["lastName"] = "Bond", ["email"] = "[email protected]", ["age"] = 34 }