MyChat Scripts: function mGetGeoPosition, get coordinates of a user's device
The function is for getting the geopositioning of a user's device by its CID (Connection ID). If a device managed to get its coordinates, it responds to the server and the current position stores in the server's database.
Syntax
function mGetGeoPosition(const iCID: int64): integer;
Parameters and return values
Parameter |
Type |
Value |
iCID |
int64 |
a unique ID of a user's connection number; |
Function result
0 function executed successfully;
-1 invalid/incorrect CID;
Example
The script gets all active Android and iOS connections of the user with UIN=6 and sends a geoposition request.
const
UIN = 6; // user UIN for test, set your own number
CLIENT_TYPE = 'android,ios';
var
iCID: integer;
sCIDList: string;
begin
sCIDList := mGetCIDSByUINAndClientType(UIN, CLIENT_TYPE);
while length(sCIDList) > 0 do begin
iCID := StrToInt(Fetch(sCIDList, ','));
mGetGeoPosition(iCID);
end;
end.
Script work result
[09:59:17] (Run "mGetGeoPosition"): Script execution time: 2 ms
[09:59:17] (Run "mGetGeoPosition"): Script done successfully.