void getWordDetail(String word) async {
var uuid = Uuid();
String wordPath = "https://openapi.youdao.com/v2/dict";
String apiKey = "appId";
String secret = "密钥";
String salt = uuid.v4();
final curentTime = getCurrentTimestamp();
final sign = sha256
.convert(utf8.encode("$apiKey$word$salt$curentTime$secret"))
.toString();
var mapParam = {
"q": word,
"langType": "en",
"appKey": apiKey,
"dicts":"ec",
"salt": salt,
"sign": sign,
"signType": "v3",
"curtime": curentTime
};
print("parameter:---$mapParam");
FormData formData = FormData.fromMap(mapParam);
Response response = await dio.post(wordPath, data: formData);
print("请求到的数据===$response=====${response.data}");
}
String getCurrentTimestamp() {
// 获取当前UTC时间
var now = DateTime.now().toUtc();
// 将DateTime转换为时间戳(秒)
int timestamp = now.millisecondsSinceEpoch ~/ 1000;
return timestamp.toString();
}