Hi,
I think that it is at that url.
Cheers.
Hi,
I think that it is at that url.
Cheers.
I’ve asked engineering…
Rob
You should be able to drop the “plugin” folder into your project (the Corona folder in your Enterprise solution) using Develephant’s link above.
Thank you Guys,
so far so great.
develephant, last two questions, I think will be interesting for many guys:
I saw in some place that in order to use Push notification (register users to channel, and later send them notification from Parse server) there is a need to use parse SDK, how that works with the parse plugin?
In general, if we found for some reason that we need to implement some parse functionality in native plugin, would that Co-exist with the parse plugin?
thank you for your time
and for your helpful answers.
Hi,
Parse eventually added the ability to handle Android registrations in the REST API, so that is completely supported in the plugin.
Though I have no concrete evidence, I don’t think you should have any issues using both if needed.
Hope that helps.
Cheers.
I am using mod_parse for a long time and it works great.
Today ported one of my games to Windows Phone and I am getting this error when calling the login method:
A request with this method cannot have a request body.
I am not an expert on http, searched the net a bit and found some information that GET should not have a body in the header?
How could I make it work on Windows Phone?
Would the Parse plugin for Corona help?
Hi,
I would need to see a pseudo-request to really understand why you would get that error. But, with that in mind, the Parse plugin is the most current and fully compliant version for the Parse REST API.
Cheers.
Here it is:
queryUri: https://api.parse.com/1/login?username=something&password=something
requestParams: {
[body] => “username=something&password=something”
[headers] => {
[Content-Type] => “application/json”
[X-Parse-Application-Id] => “myApplicationId”
[X-Parse-REST-API-Key] => “myApiKey”
}
local q = { requestId = network.request( queryUri, Parse.GET, function(e) Parse:onResponse(e); end, requestParams ),
requestType = requestType,
_callback = _callback,
}
And here is the event table from function Parse:onResponse( event )
table: 05916180 {
[name] => “networkRequest”
[isError] => true
[bytesTransferred] => 0
[phase] => “ended”
[url] => "https://api.parse.com/1/login?username=something&password=something"
[bytesEstimated] => 0
[requestId] => userdata: 00000008
}
And here is some more output from the VS console:
‘TaskHost.exe’ (CoreCLR: Silverlight AppDomain): Loaded ‘C:\windows\system32\en-US\mscorlib.debug.resources.dll’. Module was built without symbols.
A request with this method cannot have a request body.
Hi,
Are you using the new Parse plugin, or mod_parse? Because your code doesn’t look familiar to either.
If using mod_parse, then it does not appear that you are using the mod_parse client calls, is that correct?
To login a user you use the following format:
[lua]local function onLoginUser( event )
if not event.error then
print( event.response.sessionToken )
end
end
parse:loginUser( { [“username”] = “MyUser”, [“password”] = “strongpw” }, onLoginUser )[/lua]
All headers, body, and various common parameters are handled within the module itself. Perhaps I am unfamiliar with your development environment.
Also, mod_parse related issues should be addressed here: https://forums.coronalabs.com/topic/42191-a-parsecom-module-for-corona-sdk/
This thread is focused on the newer Parse plugin for Corona.
Cheers.
I am using mod_parse and using parse:loginUser.
The code if from you mod_parse module, wanted to show the exact parameters before the network.request is called.
As I said, I am using it since the first version, it works on all other operating systems (Windows, Mac, Android).
This error is from the device, Windows Phone.
Guess there must be then some kind of bug in the Corona network module for Windows Phone
Unfortunately, we can’t use plugins on Windows Phone, but I suspect it would work on it since I guess the code behind the plugin is similar to mod_parse.
Will not spam this thread anymore, just for the information (maybe someone will try to use Parse on Windows Phone).
Seems I was right, there is a bug in Coronas network call.
I tried this and got the same error as above (this time in “plain” lua):
local function networkListener( event ) if ( event.isError ) then print\_r( event ) else print ( "RESPONSE: " .. event.response ) end end local headers = {} headers["X-Parse-Application-Id"] = "my key here" headers["X-Parse-REST-API-Key"] = "my key2 here" headers["Content-Type"] = "application/json" local params = {} params.headers = headers network.request( "https://api.parse.com/1/config", "GET", networkListener, params )
I don’t get how you are supposed to maintain a session after a complete app restart so that the user does not have to login again. The module has no setter function" for SessionToken, no way of adding SessionToken in a User.me call and it does not persist the SessionToken e.g. in a sqlite db. This effectivly means that you always lose the current session at an app restart.
One alternative is to login each time the app is opened (requiring you to store the password on the device), but over time when thousands of users do it, it will quickly bloat the Session table at Parse since a new Session object is created at each login. Adding an applicationExit listener for logging out seems like an overly ugly workaround. Also, you cannot manually delete sessions at app start since they require that you have the SessionToken…
How have you guys solved this?
Nobody? Surely, I can’t be the only one having this issue?
Hi Divergent Monkey,
I’m having the exact same problem The old mod_parse had a method for setting the sessionToken to be re-used:
function Parse:setSessionToken( sessionToken )
self.sessionToken = sessionToken
return self.sessionToken
end
While I’d prefer to use the new plugin, I might have to use the old mod_parse if we can’t figure this out!
Anyone know how to do it? Parse.com documentation suggests it should be possible?
If you only have the session’s token (from previous login or session create), you can validate and fetch the corresponding session by:
curl -X GET \ -H “X-Parse-Application-Id: EOq0NmDADrPux6piVPzB9aCzfiQ1tUw2NHLOkbM0” \ -H “X-Parse-REST-API-Key: zwQExRNSfy94YYprIDX8UQWKA4Zn96Oc4lmZ7Uvy” \ -H “X-Parse-Session-Token: r:pnktnjyb996sj4p156gjtp4im” \ https://api.parse.com/1/sessions/me
Here’s hoping we find something!
Hi,
This will be addressed shortly, but it partly has to do with the REST API vs native integration. You can store the session token in a text file as an option. The Parse plugin is moving internally to Corona Labs for more parity with the native Parse SDK.
I have no knowledge of timelines, but it’s something to consider if you’re going to be using Parse heavily.
In other words, this version of the Parse plugin will not be the officially supported release eventually.
Cheers.
Hi develephant,
Thanks for the quick response! I am already storing the session token in a text file, just am unsure how to use that stored session token to restore a player’s session. Any help on that would be greatly appreciated!
Also thank you so much for this and mod_parse! Very much appreciated!
@develephant: as greatbigtree suggests, the problem is not that we don’t know how to persist the sessionToken between app restarts, but that there is no way to make use of it to restore the session later. I know that the version is just 0.x for this plugin, but since this is kind of a showstopper, would it be possible to just add a simple setter function for the time being so that I and everyone else who have put in many hours migrating from mod_parse to the plugin don’t have to revert everything? This woud be really appreciated!
Hi,
Parse would like you to think in terms of devices, more than users. A Parse Session is a device connection/login from a particular user. The reason for this is that a user could be logged in to your app from multiple devices. These are all considered Sessions to Parse, and you can expect to have multiple entries from the same user, but different devices.
When you provide Parse an “installationId” on each user login you will not have the issue of the Parse Session table filling up. How you derive this “installationId” is completely left to the developer. But Corona SDK does offer some methods to help with this.
You can include the installationId in two different ways.
–
In the config object:
If you put the installationId in the config object, you don’t need to set it in the header each time.
[lua]parse.config:installationId(“YOUR_DERIVED_INSTALLATION_ID”)[/lua]
–
In the header:
[lua]–during signup
parse.request( parse.User.create )
:data({ username=“someone”, email="me@email.com", password=“nopeeking” })
:header(“X-Parse-Installation-Id”, “YOUR_DERIVED_INSTALLATION_ID”)
:response(cb)
–during login
parse.request( parse.User.login )
:options({ username=“someone”, password=“nopeeking” })
:header(“X-Parse-Installation-Id”, “YOUR_DERIVED_INSTALLATION_ID”)
:response(cb)[/lua]
The plugin makes no assumptions about how you store this data between app launches. Its up to the developer to provide that functionality.
Something important to note is that if you want to clear the Parse Session object, you must “logout” the user via the Parse api.
[lua]parse.request( parse.User.logout )
:response(cb)[/lua]
In most cases though, you will want to keep the user “logged-in”, so you can access the Session at a later time.
Getting a previous Session
If you use an installationId, as shown above, Parse will store a Session object for each device. When you login or sign up, you can pull the sessionToken from the results. If you want to retrieve this session – in effect logging in – then you can use:
[lua]parse.request( parse.Session.me )
:header(“X-Parse-Session-Token”, “STORED_SESSION_TOKEN”)
:response(cb)[/lua]
You can also set this in the Config object:
[lua]parse.config:sessionToken(“STORED_SESSION_TOKEN”)[/lua]
Make sure to turn on the debug output to check the payload details:
[lua]parse.config:debugEnabled( true )
parse.config:debugVerbose( true )[/lua]
Most of this is covered in the Parse REST Guide, but I’m not a huge fan on how they relay the information.
I’ve written this quite hastily, so feel free to add questions or point out errors.
Cheers.