The quick answer is YES!
We just finished pushing the Android app to the market, which makes it that way. Here's how we did it:
1) Download and learn about using Cordova PhoneGap (2.2.0 - latest version) in Eclipse. This makes it easy to work with just some HTML and lots of Javascript.
2) In your JS, create methods that push out the login data using AJAX parameters. Example:
document.addEventListener('deviceready', onDeviceReady, false); function onDeviceReady() { $("#login").click(function() { $email = $("#UserEmail").val(); $pass = $("#UserPassword").val(); $.ajax({ url : yourURL + 'api/users/login', async : false, data : { 'email' : $email, 'password' : $pass }, dataType : 'json', type : 'post', success : function(result) {
3) In Cake / PHP, your user controller here will use the username and password data in the AJAX call and use it to authenticate it.
<?php class UsersController extends AppController { public $name = 'Users'; public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('api_login'); } public function api_login() { $this->autoRender = false; if ($this->request->data && isset($this->request->data['email']) && isset($this->request->data['password'])) { $arrUser = $this->User->find('all',array( 'conditions'=>array( 'email'=> $this->request->data['email'], 'password' => $this->Auth->password($this->request->data['password']), ) ) ); if (count($arrUser) > 0) { $this->Session->write('Auth.User',$arrUser[0]['User']);
This is pretty much the case. You are now authorized by CakePHP.
You do not need to use "api_", you can use any function name that you want, but this helped us to cope with what we allowed mobile users to do with web users.
Now these are just building blocks. You basically need to create an entire version of your site over the phone using HTML and Javascript, so depending on your application it might be easier to just create a responsive design on your site and allow viewing on mobile devices.
NTN!