Ready to integrate with parse.com!

sstava 7 years ago updated by icahill (Administrator) 7 years ago 4
Ok...I am at a point where I am trying to figure out the best way to integrate my rarewire app with parse.com apis and I definitely need help with a starting point!

As I see it, I have two options:
1) REST API - but, I don't think I can setup the correct HTTP header info to make this work

2) JavaScript - I have heard that the Rarewire guys might have done this already; if so, I am hoping to "borrow" some example code to jumpstart my efforts :)

I would be happy to work from a "dump" of javascript that you have used in a rarewire project. No description is necessary. I am willing to work my way through it and ask specific questions if I get stumped.

Hope you can help!

P.S. I would love to see your Parse integration for Rarewire listed in the Parse.com "official 3rd party api" list that they have on their website!
With the flexibility of our datasources we have had success with several cloud datastores. Here is user integration example with Parse:


<datasource name="parseSignUp" datasourceerror="parseSignUpError" httpmethod="post" source="" query="/result" providertype="json" httpheader="parseHeader" urlcacheduration="1" />
<httpheader name="parseHeader" Content-Type="application/json" X-Parse-Application-Id="XXXXXXXXXXXXX" X-Parse-REST-API-Key="XXXXXXXXXXXXX" />

<texttemplate name="signUpTemplate"><![CDATA[{"username":"[var:username]","password":"[var:password]","email":"[var:email]"}]]>



<style name="field-input" font="TimesNewRomanPS-BoldMT" height="38" width="200" size="24" xpos="10" color="#492417" background="#fbf4e5" padding-top="5" padding-bottom="5" padding-left="10" lvalign="center" valign="center" valignment="center" alignment="left" borderwidth="1" bordercolor="#492417" cornerradius="4"></style>
<style name="field-text" font="TimesNewRomanPSMT" size="28" xpos="10" width="200" color="#492417"></style>



<!-- classes go here -->


<panel name="background" background="#666666" height="100%" width="100%" align="center" valign="center"></panel>

<panel name="signup-frame" alias="SIGNUP-FRAME" height="100%" width="100%" align="center" valign="center">
<text name="email-text" style="field-text" height="fit" text="Email" ypos="15"></text>
<textfield name="field" alias="EMAIL" style="field-input" bottomof="email-text"></textfield>
<text name="username-text" style="field-text" height="fit" text="Username" ypos="90"></text>
<textfield name="field" alias="USERNAME" style="field-input" bottomof="username-text"></textfield>
<text name="password-text" style="field-text" height="fit" text="Password" ypos="165"></text>
<textfield name="field" alias="PASSWORD" style="field-input" password="yes" bottomof="password-text"></textfield>
<panel name="signup-submit" alias="SIGNUP-SUBMIT" height="40" width="200" xpos="10" ypos="250" background="#492417" onclick="signup-submit">
<text name="submit-text" style="field-text" size="20" width="100%" height="fit" alignment="center" align="center" valign="center" color="#FFFFFF" text="SUBMIT"></text>



<action name="signup-submit">
<assign property="var:username" value="[object:USERNAME.text]" />
<assign property="var:password" value="[object:PASSWORD.text]" />
<assign property="var:email" value="[object:EMAIL.text]" />
<assign property="datasource:parseSignUp.postContent" value="[template:signUpTemplate.content]"/>
<assign property="datasource:parseSignUp.source" value="https://api.parse.com/1/users"/>
<alert message="[template:signUpTemplate.content]"/>

<action name="postResult" datasource="parsePost">
<alert message="[datasource:parsePost.0.content]"/>

<action name="parseSignUpError">
<alert title="Network Error" message="Sign up could not be completed" />

<action name="parseSignUp">
<alert title="Sign Up Completed" message="Sign up was completed" />
<assign property="object:EMAIL.text" value="" />
<assign property="object:PASSWORD.text" value="" />
<assign property="object:EMAIL.text" value="" />



In addition to parse, we have also had success with Appcelerator's cloud services:
It is powerful library of services for creating social applications.
Thanks John!!

That could not have been easier. I copied your exact content to a wire file, pasted in my Parse application Id and REST API key and it worked; I was creating users in Parse.

I now know what I will be doing for the rest of the weekend :)
So this is extremely awesome and I'm making user accounts all day. Now I'm ready for the next step, logging in. (Parse docs here: https://www.parse.com/docs/rest#users... )

Could you add to the example and show how to handle something like this that requires sending data and receiving it? Can we reuse the datasource for everything we send to Parse? Do we need a new one for incoming data?

You're awesome!

With any restful API you can reuse the httpheader that contains your auth tokens, but you will need to create a new datasource tag for logging in. You need an httpmethod of GET and a new source.

<datasource name="parseSignUp" datasourceerror="parseSignUpError" httpmethod="post" source="" query="/result" providertype="json" httpheader="parseHeader" urlcacheduration="1" />

<datasource name="parseSignIn" datasourceerror="parseError" httpmethod="get" source="" query="/" providertype="json" httpheader="parseHeader" urlcacheduration="1"/>

<assign property="datasource:parseSignIn.source" value="https://api.parse.com/1/login?username=[eval:encodeURI(&quot;[object:SIGNIN-FORMtextfield.text]&quot;)]&amp;password=[eval:encodeURI(&quot;[object:SIGNIN-FORMtextfield.text]&quot;)]"/>