Skip to content

Database API

Henriette Steenhoff edited this page Mar 14, 2019 · 14 revisions

Database server setup

The overall setup on the server looks similar to this (fetched from this website: https://www.simplifiedcoding.net/android-mysql-tutorial-to-perform-basic-crud-operation/

The mobile application sends an HTTP request to the server through the PHP API. If the request is a valid API request the data is either stored or retrieved from the database.

Changes

When changing database structure or API remember the dependencies to the PHP API and the code of the devices using it.

Code:

  • Database (on server)
  • Java code (and related classes that implement URL)
  • PHP code (on server)
    • ClimAppAPI.php (create new version)
    • DbOperation.php

Documentation:

API

Created on the server hosted by DTU Byg. All parameters are shared preferences, each parameter links to the related preference description.

Base URL: http://localhost/ClimAppAPI/v1/ClimAppApi.php

URL Method Parameter(s)
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=createUserRecord POST _id, age, gender, height, weight, unit
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=getUsers GET
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=updateUser POST _id, age, gender, height, weight, unit
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=updateUserAge POST _id, age
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=updateUserGender POST _id, gender
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=updateUserHeight POST _id, height
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=updateUserWeight POST _id, weight
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=deleteUser&_id= userId GET _id
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=createWeatherRecord POST _id, longitude, latitude, temperature, wind_speed, humidity, cloudiness, activity_level, temp_min, temp_max
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=getWeather GET
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=createFeedbackRecord POST user_id, type, rating, txt
http://localhost/ClimAppAPI/v1/ClimAppApi.php?apicall=getFeedback GET

Localhost will of course be substituted with the global IP address of the server.

Clone this wiki locally