I was planning to add an item in my database in my remote database, the only thing I can do for now is, get JSON data from server and decode the JSON and copy it. Now I really want to know if how can I add a new row for my remote database. example Registration.
What database are you using?
You might just need to change the http “GET” to a “POST” or “PUT” … both are supported by network.request … and then including the new JSON code (as a string) as the body of the request.
local url = "url\_to\_your\_database" local httpverb = "POST" -- or "PUT" ?? local auxdata = {} auxdata.headers = {} auxdata.headers["Content-Type"] = "application/json" auxdata.headers["Authorization"] = "Basic " .. mime.b64("username:password") auxdata.body = json.encode( my\_data\_table ) function myNetworkListener( evt ) -- catch response here end network.request( url, httpverb, myNetworkListener, auxdata )
I’ve played with Apigee, Cloudant, and Kinvey and they are all variations on this theme.
If you want this to be so easy that you never have to remember there is a remote db out there look at Coronium.io
btw how can I pass any variables in my app? using the POST method? also be able to make my php back end retrieve it
What database are you using?
You might just need to change the http “GET” to a “POST” or “PUT” … both are supported by network.request … and then including the new JSON code (as a string) as the body of the request.
local url = "url\_to\_your\_database" local httpverb = "POST" -- or "PUT" ?? local auxdata = {} auxdata.headers = {} auxdata.headers["Content-Type"] = "application/json" auxdata.headers["Authorization"] = "Basic " .. mime.b64("username:password") auxdata.body = json.encode( my\_data\_table ) function myNetworkListener( evt ) -- catch response here end network.request( url, httpverb, myNetworkListener, auxdata )
I’ve played with Apigee, Cloudant, and Kinvey and they are all variations on this theme.
If you want this to be so easy that you never have to remember there is a remote db out there look at Coronium.io
btw how can I pass any variables in my app? using the POST method? also be able to make my php back end retrieve it