Page 1 of 1

Connecting to BAAS from LiveCode

Posted: Fri May 17, 2013 5:08 pm
by steveharman
Wow. If anyone's nervous about dabbling in the world of "Backend As A Service" (http://en.wikipedia.org/wiki/BaaS) systems for data storage, user auth, social integration, Amazon S3, push messaging, geo-location / GPS, sending e-mail and many more goodies besides - don't be. Took me (a silly person and LC newby) less than half an hour to get data flying into & out of StackMob using their REST API and a few LC commands. A compliment to both LC and StackMob.

Setup some HTTP headers in LC:

Accept: application/vnd.stackmob+json; version=0
X-StackMob-API-Key: [ the key given to you by StackMob]
Content-Type: application/json

Specify a URL for what you're trying to do, as per the StackMob docs - in this case to query an item I've called "resident" whose surname contains "Smith"

http://api.stackmob.com/resident?lastname[in]=Smith

And then run the response (JSON) through Monte Goulding's MergJSON to convert it into an LC array for further manipulation if required:

{
"phone_number":"0123456789",
"phone_account":"EA12399900",
"dob":"25/12/68",
"firstname":"Mary",
"lastmoddate":1368805470438,
"lastname":"Smith",
"resident_id":"1476d0ddeb1144a59df01429c42c9188",
"salutation":"Mrs",
"createddate":1368805470438,
"room":1,
"doa":"11/10/12"
}

I've been in touch with the StackMob guys (amongst others, but StackMob were the only ones kind enough to reply) about the possibility of a LiveCode SDK and it's something that has already been discussed, so fingers crossed on that one. Using the REST API is fine but I've a feeling that a native SDK would offer additional functionality (offline sync?) which isn't suited to REST so much.

Cheers,

Steve

Re: Connecting to BAAS from LiveCode

Posted: Tue May 21, 2013 8:51 am
by BvG
Hey, maybe you could write a revUp article about your experience?

contact heather here: editor@runrev.com

Re: Connecting to BAAS from LiveCode

Posted: Thu May 23, 2013 4:50 pm
by steveharman
Happy to, as soon as the current project is wrapped up and there's more time.

One part of my brain is also trying to remember to isolate the various REST calls into a stack of functions for communicating with StackMob as I go along - which might be useful for people to get started with. Nothing fancy, just easier-to-remember LC-friendly functions for say user login and queries that act as wrappers to the various REST URLs and http headers.

Steve

Re: Connecting to BAAS from LiveCode

Posted: Wed Jun 19, 2013 10:33 pm
by ebeser
I have been trying to do the same thing with Cloudant . I am a livecode newbe and would appreciate a little guidance.

It seems that Cloudant when logs in returns a cookie to the caller and that cookie is used as an authorization key. I am still trying to wrap my arms around how to do this in a live code stack, so this is where I am running into a wall, as there is no documentation on how to set up these calls, except for your news post, i have not seen any other way with the exception of the call library for SOAP.

Can you post some of your livecode stack to this forum so that i can see a good example of how you are calling stackmob so that i can translate to cloudant calls?

Re: Connecting to BAAS from LiveCode

Posted: Wed Jul 03, 2013 6:04 am
by Nakia
Would love to see where you ended up getting with this...

I have an App I have been working on for some time that uses a Time Tracking REST API and for the most part it works fine but its a clunky implementation for sure.