I'm seeking advice regarding the following plan that I have for a certain future project of mine.
- The big picture
- I want to produce a mobile client (iOS, Android, Windows Phone, etc.) that will query (read/write) to a database from my website and display its results.
- plus several other features...
I know that directly accessing the database (bypassing the web server) from the client is a bad idea especially over the internet. I think most shared webhosting plans prohibit this anyway. So here is my intended solution...
- Mobile client sends data to the webserver through an API call.
- The webserver processes the REST API call and queries the database. The webserver works as the middleware between mobile client and database server.
- The webserver receives the results from the DB queries and passes them to the mobile client.
- Mobile client displays/manipulates the data on the client-side.
My experience with APIs are limited to the consumption of Twitter, Instagram, and Google Shopping APIs. From my experience, it seems to be best to transport data between mobile and webserver in JSON format.
Now, here are my concerns...
- How can I ensure that only the logged-in users can use the API? Is OAuth the solution?
- For the REST API, is it better if it is RESTful?
The current environment of the website is on shared hosting with PHP and MySQL though I'm thinking of moving it to cloud-based services in the future. I'm planning to implement the middleware using either CodeIgniter or CakePHP or Apify.
I would appreciate if anyone can critique my plans above or present better alternatives than the ones I have in my head.
Thanks in advance.