+1

Guide to server backend

Franch 7 years ago updated by icahill (Administrator) 7 years ago 1
I am making my first app and I need it to be able to communicate with specific other devices running the same app. Specifically, one device will enter and process some data before sending pieces of that data to other devices, which will then add to that data and send this new data back to the original device (if that makes sense).

I am looking at something like amazon hosting to be an intermediary such that the devices will upload their changes to the server and devices can query the server for updates.

Is there any short guide or example for doing this with wire? If I did not provide enough information please let me know, thanks!
Here is a very simple example of how you can post data to an external server. To query that data later, just follow any tutorial on reading data from a datasource. Let me know if you have any questions. This code is no longer posting anything, but you should get the idea. 

<wire>
    <datasources>
        <!-- add http header values the service needs into the httpheader tag -->
        <httpheader name="jsonheader" Accept="text/json">
        <datasource name="validation" httpheader="jsonheader" source="" query="/" providertype="json" querycomplete="validate" httpmethod="post"/>
    </datasources>
    <main>
       <!-- this text template contains the content you want to send to the service add [var:xxx] for variables from the WIRE, etc. -->
       <texttemplate name="expired-receipt"><![CDATA[ {"format_version":1,"type":"email","email":{"to_email":"TO_ADDRESS","to_name":"TO_NAME","from_email":"FROM_EMAIL","from_name":"FROM_NAME","subject":"EMAIL_SUBJECT","body_html":"BODY_HTML_VERSION","body_text":"BODY_TEXT_VERSION"}}]]></texttemplate>


        <panel name="body" height="50%" width="50%" background="#ff0000" valign="center" align="center">
        </panel>
    </main>
    <actions>
        <action name="start" oninit="yes">
            <sync>
                <!-- assign the value of the text template to the postContent property of the datasource to be sent to the server -->
                <assign property="datasource:validation.postContent" value="[template:expired-receipt.content]" />
                 <!-- update the source of the datasource to initiate the request -->
                <assign property="datasource:validation.source" value="http://content.rarewire.com/get-apple-subscription-data/D3mwuC8bvBWUXSnq" />
            </sync>
        </action>
        <action name="validate">
            <alert message="[datasource:validation.1.status]"/>
        </action>
    </actions>
</wire>