Everything you can do on memway also works from any program that
'talks' XML. (JSON support coming soon)
In fact, the website is more an example of using the API...
It's easy and fun! All you need to do is sending strings of XML, illustrated below.
1. Getting a token
memway has to know you are, well, you.
Each time you talk to memway, you must include a temporary, alphanumeric token. Here's what you send.
<Request>
<Command>Login</Command>
<User>(user@host.com)</User>
<Password>([optional] plain_text_password, not recommended!)</Password>
<PasswordHash>([optional] MD5 hash of password)</PasswordHash>
</Request>
You must fill in either
<Password> with your plain
password, or
<PasswordHash> with a MD5 of it.
In the near future the plain password will likely not be allowed for
safety.
On *nix / Mac, you can figure out the
<PasswordHash> like this:
echo -n "your_password" | md5sum (Linux/BSD/Unix)
echo -n "your_password" | md5 (OSX)
Let's try this in your browser. We just set the 'xml' variable. This
works for GET or POST, as you'll see later.
http://memway.com/login_backend.php?xml=<Request><Command>Login</Command><User>user@host.com</User><PasswordHash>5f4dcc3b5aa765d61d8327deb882cf99</PasswordHash></Request>
If all goes well, you'll see something like this:
<Response>
<LoginStatus>1</LoginStatus>
<TokenID>aslsjo8lk1j3498jklkasdf11q</TokenID>
<UserID>1</UserID>
<Email>user@host.com</Email>
<MustChangePasswd>0</MustChangePasswd>
<RootItem>888</RootItem>
<Command>Login</Command>
<ResponseStatus>Success</ResponseStatus>
<TransID></TransID>
<Result>Success</Result>
<ElapsedTime>0.008</ElapsedTime>
</Response>
We now have a token:
aslsjo8lk1j3498jklkasdf11q. In
every memway transaction (other than this one) we will send this.
We also know that our root item is 888. Everything in memway is an
item, and every item has an id (like an inode in a filesystem). And
also like a filesystem, there is a root - the top item under which all
others live. We'll come back to that later.
2. Things in Each Response
Let's look at some of the other pieces we saw in the Login response -
pieces that are in EVERY response,
<Response>
<Command>Login</Command>
<ResponseStatus>Success</ResponseStatus>
<TransID></TransID>
<Result>Success</Result>
<ElapsedTime>0.008</ElapsedTime>
</Response>
<Command>Login</Command> just repeats back the command
you sent. Sometimes the part of our program that proceses replies
from memway is detached from the part that sends queries. This is part
of memway's design to make each response self-sufficient and easy to
process.
<ResponseStatus>Success</ResponseStatus>