REST API

Aufruf

Sie benötigen Ihren API Key (key). Diesen finden Sie unter Administartion -> Firma.

Antwort

Alle API-Aufrufe liefern Ihnen ein JSON Objekt zurück.

Beispiele

mit JavaScript

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>

var api = "asdasdasdasdas";

function days2(data) {
var url = "https://app.saas.de/rest/api/time/days/" + api;

$.ajax({
type : "POST",
url : url,
contentType : "application/json;charset=utf-8",
data : JSON.stringify(data),
success : function(data) {
if (data != null && typeof data == "string") {
data = JSON.parse(data);
}

console.log(data);
},
error : function() {
console.log("error");
}
});
}
function days() {
days2({
"email" : "john@saas.de", // optional, ohne => ganze Firma
"start" : "2014-01-01",
"end" : "2014-01-31"

});
}
</script>
</head>
<body>
<button onclick="days()">Lade Tage</button>
</body>
</html>

 mit PHP

<?php

$url = "https://app.saas.de/rest/api/time/overview/".api;
$params = array();
$params['email'] = "john@saas.de";

$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($params)))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

$result = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $header_size);
$result = substr($result, $header_size);
curl_close($ch);

print_r(json_decode($result, true));
?>

 

Fehlercodes

  CODE             DESC
  0                     Alles OK => kein Fehler
  1                     Mitarbeiter nicht gefunden
  2                     Firma nicht aktiv
  3                     Falsche Authentifizierung‎
  4                     Buchung konnte nicht erstellt werden