setToken function
void
setToken(
- String token, {
- bool debug = true,
})
Implementation
void setToken(String token,{bool debug=true}) async {
Map<String, String> headers = {
'linkr-token':token
};
final url = Uri.https('www.api.linkrbot.com', '/test');
var response = await http.get(url, headers: headers);
var res = convert.jsonDecode(response.body);
final resTime = double.parse(res['timestamp'].toString());
final reqTime = ((DateTime.now().millisecondsSinceEpoch - resTime)).round().abs();
print(
"\x1b[32mSuccessfully logged in to \x1b[35mhttps://www.api.linkrbot.com\n\x1b[32mToken: \x1b[35m"+
res['token'] +
"\n\x1b[32mWhen: \x1b[35m" +
reqTime.toString() +
'ms ago\x1b[0m'
);
}