I am trying to communicate to my server using Android Application. I googled it and get to know about REST API. I followed the article http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/, and wrote backend code.
As far as I know, what I got is nothing but backend code, which manages various responses from the user. Earlier, what I doing was, coding manually like this:
public function add_data()
{
// Adding data to the table using this controller.
if ( isset($_POST['submit']))
{
if ( isset($_POST['heading']) && isset($_POST['content']) && isset($_POST['references']))
{
// echo "I am in post";
if ( !empty($_POST['heading'] && !empty($_POST['content'] && !empty($_POST['references']))))
{
$this->load->model('Admin_model');
$this->Admin_model->insert_data($_POST['heading'],$_POST['content'],$_POST['references']);
// echo "Data is inserted successfully.";
}
}
}
$this->admin();
}
What above code does add data to the database.
Now, I want to know how the REST API coding is different from the backend coding in a framework ( Say code igniter, in case of PHP)? The backend coding gives output in json form.
What are some better ways to communicate with the server in android application?
Please help me.