7
7
header ('Connection: keep-alive ' );
8
8
9
9
//get the session cookie
10
- $ session = json_encode (get_TraccarSession ("http ://127.0.0.1:8082 /api/session?token=$ TraccarAPIToken " ));
10
+ $ session = json_encode (get_TraccarSession ("$ protocol :// $ TraccarIP : $ TraccarPort /api/session?token= $ TraccarAPIToken " ));
11
11
12
12
$ api_result = json_decode ($ session , true );
13
13
$ JSESSIONID = $ api_result ['JSESSIONID ' ];
14
14
15
15
//get the Traccar positions
16
- $ positions = get_TraccarPosition ("http ://127.0.0.1:8082 /api/positions?token=$ TraccarAPIToken " ,$ JSESSIONID );
16
+ $ positions = get_TraccarPosition ("$ protocol :// $ TraccarIP : $ TraccarPort /api/positions?token= $ TraccarAPIToken " ,$ JSESSIONID );
17
17
18
18
$ json = json_decode ($ positions );
19
19
30
30
// );
31
31
32
32
//forward the positions to the FTS API endpoint
33
- $ result = get_FTSAPI ($ item ->id , $ item ->latitude , $ item ->longitude );
33
+ $ result = get_FTSAPI ($ item ->id , $ item ->latitude , $ item ->longitude , $ protocol , $ FTSIP , $ FTSAPIPort , $ FTSAPIToken );
34
34
35
35
$ markers [] = json_encode (
36
36
array (
@@ -83,7 +83,7 @@ function get_TraccarPosition($url,$JSESSIONID) {
83
83
return $ file ;
84
84
}
85
85
86
- function get_FTSAPI ($ id , $ latitude , $ longitude , $ FreeTakServerAPIToken ) {
86
+ function get_FTSAPI ($ id , $ latitude , $ longitude , $ protocol , $ FTSIP , $ FTSAPIPort , $ FTSAPIToken ) {
87
87
88
88
//generate GUID
89
89
$ guid = vsprintf ('%s%s-%s-4000-8%.3s-%s%s%s0 ' ,str_split (dechex ( microtime (true ) * 1000 ) . bin2hex ( random_bytes (8 ) ),4 ));
@@ -99,14 +99,14 @@ function get_FTSAPI($id, $latitude, $longitude, $FreeTakServerAPIToken) {
99
99
"team " => "Red "
100
100
);
101
101
102
- $ ch = curl_init ("http ://127.0.0.1:19023 /ManagePresence/postPresence " );
102
+ $ ch = curl_init ("$ protocol :// $ FTSIP : $ FTSAPIPort /ManagePresence/postPresence " );
103
103
//set cURL options
104
104
curl_setopt (
105
105
$ ch ,
106
106
CURLOPT_HTTPHEADER ,
107
107
array (
108
108
'Content-Type: application/json ' ,
109
- 'Authorization: ' .$ FreeTakServerAPIToken
109
+ 'Authorization: ' .$ FTSAPIToken
110
110
)
111
111
);
112
112
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
0 commit comments