Foren / National / Russian / Android и Cotonti

GHengeveld
#30823 27. September 2011, 08:25

I think that method is for http basic authentication. Cotonti uses a custom authentication process. You have to do a POST with the login details (just like on the website) and then fetch the session id so you can use that in the following requests. This last bit is where it gets tricky. Cotonti doesn't return the session id, is uses php sessions. A module or plugin will have to handle that.

Added 2 hours later:

Here's my API framework for Cotonti. It works like this:

  1. GET api.php?a=init
  2. Response JSON contains 'xk', Cotonti's security key and 'signature', a sha-1 hash of the response body.
  3. POST api.php?m=users.auth with params: rusername, rpassword, x (value of xk from init), signature (sha-1 hash of POST body)
  4. Response JSON contains 'xk', 'session' (the session ID), 'signature' among others.

All requests are GET or POST. All responses are in JSON format.

This is basically a framework for writing a site-wide API. I've provided simple functions so it's relatively easy to write APIs for your own modules. Actually this is already in use for a commercial iPhone app.


Dieser Beitrag wurde von GHengeveld (am 27. September 2011, 10:36, vor 13 Jahre) bearbeitet