php - seeking advise for a mobile client-server application strategy -
i'm seeking advice regarding following plan have future project of mine.
- the big picture
- i want produce mobile client (ios, android, windows phone, etc.) query (read/write) database website , display results.
- plus several other features...
i know directly accessing database (bypassing web server) client bad idea on internet. think shared webhosting plans prohibit anyway. here intended solution...
- mobile client sends data webserver through api call.
- the webserver processes rest api call , queries database. webserver works middleware between mobile client , database server.
- the webserver receives results db queries , passes them mobile client.
- mobile client displays/manipulates data on client-side.
my experience apis limited consumption of twitter, instagram, , google shopping apis. experience, seems best transport data between mobile , webserver in json format.
now, here concerns...
- how can ensure logged-in users can use api? oauth solution?
- for rest api, better if restful?
the current environment of website on shared hosting php , mysql though i'm thinking of moving cloud-based services in future. i'm planning implement middleware using either codeigniter or cakephp or apify.
i appreciate if can critique plans above or present better alternatives ones have in head.
thanks in advance.
rest best architecture you're looking for. more restful get, better.
oauth authorization protocol, handles websites has authorization use credentials. authorization different authentication, although 1 can use authorization party ensure authentication.
the choice on oauth depends on services you're building on. example, if application based on twitter, makes sense use twitter oauth authentication.
if service provide own credentials, every user having own username/password stored you, oauth not best choice. on scenario, you'll need setup oauth client , oauth server, not necessary.
for own authentication, http digest auth choice: simple implement, lot of libraries support , it's secure enough cases.
avoid sessions , cookies in php. rest stateless , features full of client state on server.
if 1 day need expand service more servers, synchronizing sessions between them painful.
take care of cache headers expires, etag , last-modified. improve overall performance of api , can setup reverse proxy (a middleware between server , client) can cache things you.
public data on api should not require authentication. when caching authenticated data, can't share cache between different users. public data cache can shared.
both json , xml easy handle , manipulate. json better, xml is. see this answer more info differences on these formats.
take @ respect\rest, varnish , frapi. these great tools rest apis.
Comments
Post a Comment