<?php
include('traccarApi.php');
$email = 'arvid1234';
$password = 'arvid123';
$name = 'arvid123';
$attributes = '{}';
$sessionId='-1';
$uniqueId='2345';
$phone='09094126387';
$model='NA';
$category='NA';
$a = gps::deviceAdd($sessionId,$name,$uniqueId,$phone,$model,$category,$attributes);
$response = $a->response;
$responseCode = $a->responseCode;
if($responseCode == '200'){
echo ('true');
}else{
echo 'Invalid Data Try Again';
}
?>
public static function deviceAdd($sessionId,$name,$uniqueId,$phone,$model,$category,$attributes){
$id = '-1';
$sessionId=$sessionId;
$attributes = $attributes;
$name=$name;
$uniqueId=$uniqueId;
$phone=$phone;
$model=$model;
$category=$category;
$data='{"id":"'.$id.'","name":"'.$name.'","uniqueId":"'.$uniqueId.'","phone":"'.$phone.'","model":"'.$model.'","category":"'.$category.'","attributes":'.$attributes.'}';
return self::curl('/api/devices','POST',$sessionId,$data,array(self::$jsonC));
}
Hi anton,
I really dont know what or how to create a session, by the way here is the error message when executing the above code
HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:113 < ...)401
Hi! i have te same problem, i can't create a "session" via traccarApi.php :/ help, I have read the documentation, but it does not indicate how to start it
<?php include('traccarApi.php'); $email = 'arvid1234'; $password = 'arvid123'; $name = 'arvid123'; $attributes = '{}'; $sessionId='-1'; $uniqueId='2345'; $phone='09094126387'; $model='NA'; $category='NA'; $a = gps::deviceAdd($sessionId,$name,$uniqueId,$phone,$model,$category,$attributes); $response = $a->response; $responseCode = $a->responseCode; if($responseCode == '200'){ echo ('true'); }else{ echo 'Invalid Data Try Again'; } ?> public static function deviceAdd($sessionId,$name,$uniqueId,$phone,$model,$category,$attributes){ $id = '-1'; $sessionId=$sessionId; $attributes = $attributes; $name=$name; $uniqueId=$uniqueId; $phone=$phone; $model=$model; $category=$category; $data='{"id":"'.$id.'","name":"'.$name.'","uniqueId":"'.$uniqueId.'","phone":"'.$phone.'","model":"'.$model.'","category":"'.$category.'","attributes":'.$attributes.'}'; return self::curl('/api/devices','POST',$sessionId,$data,array(self::$jsonC)); }