Форумы / National / Russian / Android и Cotonti

Yusupov
#1 26.09.2011 13:56

Кто-нибудь пробовал организовать в андроид-приложении авторизацию на сайте на базе cotonti?

GHengeveld
#2 26.09.2011 17:31

Do you mean an API? I've been working on that.

Yusupov
#3 26.09.2011 17:47
#30815 GHengeveld:

Do you mean an API? I've been working on that.

Yes, I want to provide access to data on the site through an android application. For an application to login via WebView. I'm trying to make it through the method setHttpAuthUsernamePassword, but nothing happens ...

Sorry for my english)

esclkm
#4 26.09.2011 18:39

я думал.

но имхо надо сначало вывести весь котонти в виде JSONмассива а на это надо плуг написать

littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
GHengeveld
#5 27.09.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.

Отредактировано: GHengeveld (27.09.2011 10:36, 12 лет назад)