Is Corona SDK going to support the PARSE API?

Hi there

I’ve been looking at the stuff provided at www.parse.com

It looks pretty useful - would there be any chance of implementing access to it through the Corona SDK?

Best regards

JB [import]uid: 58328 topic_id: 19842 reply_id: 319842[/import]

You should be able to use parse.com right now using their REST API and the network.request() api call.

The biggest pain I see is that you have to store the objectID somewhere.

Example create object code:

local json = require("json")  
local mime = require("mime")  
  
local MasterKey = "yourmasterkeyfromparse.com"  
local ApplicationID = "yourappIDfromparse.com"  
  
local function networkListener( event )  
 if ( event.isError ) then  
 print( "Network error!")  
 else  
 print ( "RESPONSE: " .. event.response )  
 local responseData = json.decode(event.response)  
 local objectId = responseData["objectId"]  
 end  
end  
   
headers = {}  
   
headers["Content-Type"] = "application/json"  
headers["Accept-Language"] = "en-US"  
headers["Authorization"] = "Basic " .. mime.b64(ApplicationID .. ":" ..   
MasterKey)  
  
postData = json.encode(myDataTable)  
   
local params = {}  
params.body = postData  
params.header = headers  
   
network.request( "https://api.parse.com/1/classes/GameData", "POST", networkListener, params)  

But in looking at the API call for network.request, only GET and POST are supported, but there is some evidence that DELETE works. PUT on the other hand may or may not work and that would make doing update’s a bit more difficult.
[import]uid: 19626 topic_id: 19842 reply_id: 77014[/import]

As corona’s network.request does not officially support PUT and DELETE requests on device builds, the official answer is no. You could always write your own php webservice and issue parse.com requests over your own service (like a gateway), but this also limits one of parse’s important features: scalability.

parse and stackmob are freaking good services… i beg ansca to support PUT and DELETE :slight_smile: [import]uid: 11686 topic_id: 19842 reply_id: 77266[/import]

Anyone found a way to use the Parse API yet (or any of the other BaaS API’s?

This is a huge priority. [import]uid: 76002 topic_id: 19842 reply_id: 100890[/import]

Parse ( + Put and Delete ) does work with Corona on iOS ( I didn’t test android)

Se this thread #13 for an example.
https://developer.anscamobile.com/forum/2011/09/27/parse-backend [import]uid: 13632 topic_id: 19842 reply_id: 100895[/import]

Thanks, ojnab! Theoretically, should Stackmob’s REST API work, too? [import]uid: 135391 topic_id: 19842 reply_id: 100903[/import]

looks like corona now supports PUT DELETE and HEAD on android as of build 782: http://developer.anscamobile.com/release/2012/782 [import]uid: 12822 topic_id: 19842 reply_id: 100912[/import]

Yes, you can use StackMob with Corona. Take a look at our docs here http://www.stackmob.com/devcenter/docs/Datastore-API#a-making_api_calls and just open up a support ticket if you have any questions!

Ty [import]uid: 42154 topic_id: 19842 reply_id: 101384[/import]

Thanks for the response, Ty. Someone on another thread said that Corona couldn’t support REST API calls using OAuth (like Stackmob requires). Not true? [import]uid: 135391 topic_id: 19842 reply_id: 101387[/import]

I’ll do some digging but I don’t see why not. We use two-legged oauth so it is just signing the request and setting some custom headers. Which I believe are all perfectly doable with Corona.

Ty [import]uid: 42154 topic_id: 19842 reply_id: 101390[/import]

There’s a Parse sample module in the code library now:
http://developer.anscamobile.com/code/parse-corona-sdk
[import]uid: 1560 topic_id: 19842 reply_id: 101461[/import]

I’ve been working with my own Parse lib for Corona (my app currently uses Amazon Simple DB and S3, through my own Corona libs, but I think Parse would be a much better solution).

My main issue is that my app only uses Facebook auth, and to use FB auth with Parse you need the access token and expiration from Facebook login. For reasons known only to our Corona overlords, they chose not to provide the expiration. So I’m blocked there. I filed a feature request, but am not holding my breath.

Also, I have been complaining about the horrible network IO support in Corona for a while. They have made a coupe of small, but important changes (you can now use verbs other than get/post, and they actually give you the status result from the http request - yay).

I’ve gotten around the limitations of their network IO with S3 and SimpleDB by using LuaSocket instead, which is awesome (in that it is a complete and well designed network IO library). The problem is that LuaSocket doesn’t support SSL, so when I’ve looked at doing Corona libraries for Parse, Dropbox, etc, I’m back to having to use the crappy network.request/network.download if I go that route.

So what are my complaints? Neither network.request or network.download provide access to http response headers, neither of them provide status (bytes uploaded/download, percent complete), neither of them are cancellable, network.request corrupts binary responses on Android, network.request has no way to stream body content from a file (making medium-large file uploads take place in memory), network.download writes/overwrites the response file even on error (so, for example, if an image download fails, it will write whatever the server provided in the error response to the image file you were expecting, meaning if you want to get the error info you have load it from the file, guess its content type, process it, and delete the file - and of course always write to a temp file to avoid overwriting a valid file), etc, etc.

I’ve filed bugs or feature requests for all of this.

So the problem is that once you are committed to SSL (as with Parse/Dropbox/others), you’re back to having to work with the crappy async networking support in Corona. And it’s just not suitable for a real app.

In a real app, you need to do network operations that might take more than a second or two, that might fail, that might hang, etc. You want to show the user status so they can see whether the operation is progressing and maybe estimate how long it will take and decide to cancel it. Maybe the app decides that a network operation is not thriving and wants to cancel it. You get the idea. For the standard Corona “Hello World” where you download an image file and show it on the screen in 5 lines of code, it works great. But if you want to write real networking code for a real app using these APIs, you’re going to be in for a real treat. Your user gets to wait as long as it takes, with no status, no cancelling, your app can’t even cancel, and you’re still going to have to tap dance around the bugs.

I’ve taken the postion that I just have to wait until Ansca fixes these APIs before I waste more of my time writing network libs for Corona that are just going to suck in real usage anyway because of limitations in the underlying networking support.

That being said, if you don’t care about progress/cancelling and you’re willing to use network.download when working with binary responses, and you’re not going to do any larger than available memory file uploads, and you don’t need Facebook support, then Parse is pretty straightforward (using the lib referenced above or just calling the REST APIs directly). You will not get some of the information they provide in the response headers, but from looking at the API, I think you can reconstruct it from the data you do get (for example, you won’t get the “location” header with the url of a new resource, but you can build that from the object ID you get back in the JSON part of the response).
[import]uid: 111481 topic_id: 19842 reply_id: 104502[/import]

+1 for Corona needing to give us the expiration from Facebook login. Please make this simple fix soon! [import]uid: 76002 topic_id: 19842 reply_id: 105324[/import]

I’ve had some emails back and forth with Walter after filing the feature request for the token expiration, so I take that as a good sign. [import]uid: 111481 topic_id: 19842 reply_id: 105326[/import]

Bob,

You’ll be happy to know that 2012.812, 5 days after your comment, Ansca added the expiration info for the Facebook token.

As to the rest you’ve rightfully pointed out is needed… :slight_smile:

Mike [import]uid: 49460 topic_id: 19842 reply_id: 108402[/import]

@fremontmj -

Yeah, that was not a coincidence. I made a feature request, had a few emails back and forth with Ansca (Walter) and one with Parse just to clarify what they needed, and it got implemented shortly after. I was super happy about that as you can imagine (now I’ve submitted over 15 bugs and this is the only time that’s ever happened anything like that fast - but still - it was pretty nice).

I got sidetracked on another project, but I intend to come back and work on my Parse lib soon (I know there are some other Parse libs out there, but none really to my liking).

I also wrote a giant feature request laying out all of the shortcomings of the Corona async http support - and their response to that was basically “we’ll take that under advisement” and then they closed the bug. Hard to know what to make of that, but I’m not holding my breath. Best case is they’ll open up to extensions (as they have hinted) and then someone can implement some decent network support. I don’t know why LuaSocket + LuaSec + LuaLanes isn’t the right answer (except that they’re probably too obtuse for most Corona users to get their heads around).

Bob [import]uid: 111481 topic_id: 19842 reply_id: 108437[/import]