1. Web Service for Mobile
6 jan 2013 @ Sripatum University
Anuchit Chalothorn
anoochit@gmail.com
2. About
● Not a Teacher or Instructor
● Not a Programmer or Developer
● Senior Software Engineer at SIPA
● Content writer not speaker
● I use Linux :)
3. Rules
● You can leave every time.
● If you don't understand and you don't want to
ask you can leave.
● If you want to learn by yourself and I'll give
you a resources, you can leave.
● If you don't understand at all and everything
as I said, you can leave and I'll give a
resources, you can learning by yourself.
4. Quote
“If you cannot do great things, do small things
in a great way” - Napoleon Hill
5. What you have learn ?
● Web Service
● SOAP
● RESTful
○ Mobile App
○ REST Server
● How to interact between 2 devices
6. REST "No" official standard
But 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
7. Small things
Make your web service using RESTful for your
WattPad-liked project, by the way answer this
questions :
● What, Who, Where, When
● How, How much and How many
8. 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, it's too easy
○ CakePHP has own ORM (object-relational mapping)
○ Everything is Array
○ Extension and Plug in support
○ You can hook anyware
9. CakePHP Framework
The CakePHP framework provides a robust
base for your application. And since the
framework follows the principles of MVC, it
allows you to easily customize and extend most
aspects of your application.
10. 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()
11. 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
12. 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'));
13. Small thing for you
● CakePHP Cook Book
○ http://book.cakephp.org/2.0/en/index.html
14. You should know
After 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