Web Service for Mobile 6 jan 2013 @ Sripatum University Anuchit Chalothorn firstname.lastname@example.org
About● Not a Teacher or Instructor● Not a Programmer or Developer● Senior Software Engineer at SIPA● Content writer not speaker● I use Linux :)
Rules● You can leave every time.● If you dont understand and you dont want to ask you can leave.● If you want to learn by yourself and Ill give you a resources, you can leave.● If you dont understand at all and everything as I said, you can leave and Ill give a resources, you can learning by yourself.
Quote“If you cannot do great things, do small thingsin a great way” - Napoleon Hill
What you have learn ?● Web Service● SOAP● RESTful ○ Mobile App ○ REST Server● How to interact between 2 devices
REST "No" official standardBut you should follow design guid line● RESTful API Design ○ http://www.freshblurbs. com/blog/2011/06/19/pragmatic-restful-api-design. html● Learn REST ○ http://www.restapitutorial.com
Small thingsMake your web service using RESTful for yourWattPad-liked project, by the way answer thisquestions :● What, Who, Where, When● How, How much and How many
REST with PHP Framework● CakePHP is NOT REST Framework● CakePHP is PHP Framework follow the MVC principle● You can use nature of CakePHP implement REST server, its too easy ○ CakePHP has own ORM (object-relational mapping) ○ Everything is Array ○ Extension and Plug in support ○ You can hook anyware
CakePHP FrameworkThe CakePHP framework provides a robustbase for your application. And since theframework follows the principles of MVC, itallows you to easily customize and extend mostaspects of your application.
Install CakePHP● Download and extract CakePHP● Change permission for tmp directory● Config security and encryption● Config database connection● Define your model and relation according to your database schema● Plan your URI and create new controller, model and view for each services● Test with simple method like index()
JSON View● Enable json and or xml extensions with Router::parseExtensions() in Router to handle multiple extensions eg. Router:: parseExtensions(json); for json extension.● Add the RequestHandlerComponent to your controller’s list of components
JSON View● Using Data View to set serialize key in special view variable. eg. $this->set (_serialize, array(data));● If you are lazy you can force to use default view to render eg. $this->render(null, ajax,/ajax/ajax);● In data view in view file just show in json data eg. json_encode(compact(posts));
Small thing for you● CakePHP Cook Book ○ http://book.cakephp.org/2.0/en/index.html
You should knowAfter this class you should continue to study● Cloud Service on any your platform ○ IaaS ○ PaaS● Try to make your Mobile Application call these services ○ OAuth2 ○ Social Network