A simple REST interface for uploading and viewing GPS coordinates. To be used in conjunction with a client app.
##How to use
- Download ZIP file for this project and copy it to a directory on your website e.g.
www.example.org/mytracker - Open the
resources/constants.phpfile in a text editor and customise the following constants, the majority of them can be left as their default values but it's worth checking: *GOOGLE_MAPS_API- Add your Google Maps API key *MAX_DEVICES- Maximum number of devices, use -1 for unlimited devices (default: -1) *SPEED_MODE- Tells the system whether to show speeds for cyclists, runners or both. (default: both) *DEV_MODE- Enables developer options such as viewing the SQLite tables and constants, if you're not a developer leave this mode off (default: false) *GOOGLE_ANALYTICS_TRACKING_ID- Google Analytics Tracking ID (optional) (default: none set) - Use an app on your phone to periodically upload the users location.
- The first call should be to
http://www.example.org/mytracker/api/v1/init/dl(wheredlis the download key that will be used to access view the tracking points) with the followingPOSTparameters: *reset-1to clear the previous GPS coordinates.0to keep them *device- a unique, secret, ID for the device. - Initializing will create the SQLite database and generate an upload key used to add GPS coordinates to the database. The response will be a JSON string in the following format:
{"success":true,"key":"DtBFiyiwvH62YfZ","device":"abc123"} - The JSON string contains three fields:
*
success- true if the initialisation was a success *key- The key to be used to upload GPS coordinates. The system will generate a key regardless of success so always checksuccessbefore using the key *device- The device ID which was originally given - After successful initialisation coordinates can be uploaded by accessing
http://www.example.org/mytracker/api/v1/update/ul(whereulis the upload key that is used to add coordinates to the database) with the followingPOSTparameters: *lat- The latitude value *long- The longditude value *dt- The timestamp for the coordinates (in milliseconds since midnight 1 January 1970) *speed(optional) - The speed value (in m/s) *alt(optional) - The altitude (in m) - The response to this will be a JSON string in the following format:
{"response":true,"date_time":"1430425590477"} - The JSON string contains three fields:
*
response- true if the upload was successful *date_time- the timestamp provided when the upload was sent - allows you to match a response to a given upload request - Repeat 2.4 - 2.6 periodically to provide live tracking
- Details of your position can be viewed by accessing
http://www.example.org/mytracker/track/downloadwheredownloadis the download key set in step 2.1. - GPX files can be downloaded for each route by accessing
http://www.example.org/mytracker/track/download.gpxwheredownloadis the download key set in step 2.1.