REST API for Android using PHP
How to create rest api for android using php?
Application Programming Interface (API)
An API is perfect way to communication between an app (Android or iPhone) and a server. Whenever user send request to android or ios app, that send request to server and server revert back with response either in XML or JSON format.
REST is very simple and secure compared to other methods like Simple object access protocol (SOAP), The Common Object Request Broker Architecture (CORBA) and Web Service Description Language ( WSDL ). The RESTful API supports the most commonly used HTTP methods (GET, POST, PUT and DELETE).
- GET to retrieve and search data
- POST to add data
- PUT to update data
- DELETE to delete data
How to communication of mobile app to server using PHP API ?
Android apps can communicate by one of the following:
1. Web Sockets - For real time apps like chat, video calling app.
2. HttpClient - For non-real time apps like order app, ecommerce app.
Web Sockets allows real time applications such as chat, voice calls, etc. to connect to the internet in a TCP stream rather than making HTTP requests.
HttpClient is used where the data is obtained in a non-real time mode. These maybe forms, reading article apps, etc.