Register Now
Code Examples

We try to make it as easy as possible for you to receive the locations stored on our server. We listed therefore code snippets to do so for some of the most popular programming languages on this page.

Website Integration:
Probably the most important part is the website integration with the help of Google Maps. Insert the following code between the
<body>...</body>
tags of your webpage.
jQuery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
var ids = {"user_id": "USER_ID", "device_id": "DEVICE_ID"};
$.post("https://locationtracker.online/api/getLocation.php", ids, function(data, textStatus) {
var url = "https://maps.google.com/maps?q=" + data.latitude + "," + data.longitude + "&z=16&output=embed";
$("#google_maps").attr("src", url);
}, "json");
</script>
<iframe id="google_maps" src="https://maps.google.com?output=embed" frameborder="0" style="border: 1px solid black; height: 450px; width: 450px;"></iframe><br>
<small>This map was created with <a href='https://locationtracker.online'>LocationTracker.Online</a> and <a href='https://maps.google.com'>Google Maps</a>.</small>
Language Snippets:

For the more advanced users here the code snippsets needed to ingetrate our API with your Apps in other programming languages.
PHP
curl_setopt_array($ch = curl_init(), array(
CURLOPT_URL => "https://locationtracker.online/api/getLocation.php",
CURLOPT_POSTFIELDS => array(
"user_id" => "USER_ID",
"device_id" => "DEVICE_ID",
),
CURLOPT_SAFE_UPLOAD => true,
));
$response_json = curl_exec($ch);
curl_close($ch);
JAVASCRIPT
var response_json = "";
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
response_json = this.responseText;
};
xhttp.open("POST", "https://locationtracker.online/api/getLocation.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("user_id=USER_ID&device_id=DEVICE_ID");
PYTHON 2
import httplib, urllib
conn = httplib.HTTPSConnection("locationtracker.online:443")
conn.request("POST", "/api/getLocation.php",
urllib.urlencode({
"user_id": "USER_ID",
"device_id": "DEVICE_ID",
}), { "Content-type": "application/x-www-form-urlencoded" })
response = conn.getresponse()
response_json = response.read()
PYTHON 3
import http.client, urllib
conn = http.client.HTTPSConnection("locationtracker.online:443")
conn.request("POST", "/api/getLocation.php",
urllib.urlencode({
"user_id": "USER_ID",
"device_id": "DEVICE_ID",
}), { "Content-type": "application/x-www-form-urlencoded" })
response = conn.getresponse()
response_json = response.read()
MATLAB
response_json = webwrite('https://locationtracker.online/api/getLocation.php','user_id','USER_ID','device_id','DEVICE_ID')
PERL
use LWP::UserAgent;
my $response = LWP::UserAgent->new()->post(
"https://locationtracker.online/api/getLocation.php", [
"user_id" => "USER_ID",
"device_id" => "DEVICE_ID",
]);
$respone_json = $response->decoded_content;
C
#include <curl/curl.h>
#include <string.h>
#include <stdlib.h>

struct string {
char *ptr;
size_t len;
};

void init_string(struct string *s) {
s->len = 0;
s->ptr = malloc(s->len+1);
s->ptr[0] = '\0';
}

size_t WriteCallback(void *ptr, size_t size, size_t nmemb, struct string *s) {
size_t new_len = s->len + size*nmemb;
s->ptr = realloc(s->ptr, new_len+1);
memcpy(s->ptr+s->len, ptr, size*nmemb);
s->ptr[new_len] = '\0';
s->len = new_len;
return size*nmemb;
}

CURL *curl;
struct string response_json;
init_string(&response_json);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://locationtracker.online/api/getLocation.php");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "user_id=USER_ID&device_id=DEVICE_ID");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
free(response_json.ptr);
To enable LibCurl in XCode, go to the Build Settings for the target, and add -lcurl to Other Linker Flags (OTHER_LDFLAGS).
C++
#include <string>
#include <curl/curl.h>

static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp) {
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}

CURL *curl;
std::string response_json;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "https://locationtracker.online/api/getLocation.php");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "user_id=USER_ID&device_id=DEVICE_ID");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_json);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
To enable LibCurl in XCode, go to the Build Settings for the target, and add -lcurl to Other Linker Flags (OTHER_LDFLAGS).
C#
var parameters = new NameValueCollection {
{ "user_id", "USER_ID" },
{ "device_id", "DEVICE_ID" }
};
using (var client = new WebClient()) {
client.UploadValues("https://locationtracker.online/api/getLocation.php", parameters);
}
JAVA
import java.net.*;
import java.io.*;

URL url = new URL("http://locationtracker.online/api/getLocation.php");
byte[] postDataBytes = "user_id=657957e3b43b8d4a0417241f4e225ea5&device_id=477a5063744e30fbff13da614a37ed24".getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder builder = new StringBuilder();
String aux = "";
while ((aux = in.readLine()) != null) {
builder.append(aux);
}
String response_json = builder.toString();
RUBY
require "net/https"
url = URI.parse("https://locationtracker.online/api/getLocation.php")
req = Net::HTTP::Post.new(url.path)
req.set_form_data({
:user_id => "USER_ID",
:device_id => "DEVICE_ID",
})
res = Net::HTTP.new(url.host, url.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
response = 0
res.start {|http| response = http.request(req) }
response_json = response.body
UNIX COMMAND LINE
response_json=$(curl -s \
--form-string "user_id=USER_ID" \
--form-string "device_id=DEVICE_ID" \
https://locationtracker.online/api/getLocation.php)
SWIFT 3
var request = URLRequest(url: URL(string: "https://locationtracker.online/api/getLocation.php")!)
request.httpMethod = "POST"
var paramString = "user_id=USER_ID&device_id=DEVICE_ID"
request.httpBody = paramString.data(using: String.Encoding.utf8)
let task = URLSession.shared.dataTask(with: request) { (response_json, response, error) in
...
}
task.resume()

If no example code is listed for the programming language you are using, please visit the Developer API page to find out what our API expects and try to make it yourself. If you then still need help or would like to post your solution here, please feel free to contact me asap.

You can also visit the website of a similar project called PushOver to look for more code examples.