Connecting to BAAS from LiveCode

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
steveharman
Posts: 26
Joined: Fri Apr 12, 2013 11:03 am

Connecting to BAAS from LiveCode

Post by steveharman » Fri May 17, 2013 5:08 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Connecting to BAAS from LiveCode

Post by BvG » Tue May 21, 2013 8:51 am

Hey, maybe you could write a revUp article about your experience?

contact heather here: editor@runrev.com
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

steveharman
Posts: 26
Joined: Fri Apr 12, 2013 11:03 am

Re: Connecting to BAAS from LiveCode

Post by steveharman » Thu May 23, 2013 4:50 pm

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

ebeser
Posts: 1
Joined: Mon Jun 10, 2013 11:36 am

Re: Connecting to BAAS from LiveCode

Post by ebeser » Wed Jun 19, 2013 10:33 pm

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?

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Connecting to BAAS from LiveCode

Post by Nakia » Wed Jul 03, 2013 6:04 am

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.

Post Reply