File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -763,19 +763,16 @@ void UniversalTelegramBot::closeClient() {
763
763
bool UniversalTelegramBot::getFile (String *file_path, long *file_size, String file_id)
764
764
{
765
765
String command = " bot" + _token + " /getFile?file_id=" + file_id;
766
- String response =
767
- sendGetToTelegram (command); // receive reply from telegram.org
768
- DynamicJsonBuffer jsonBuffer;
769
- JsonObject &root = jsonBuffer.parseObject (response);
770
-
766
+ String response = sendGetToTelegram (command); // receive reply from telegram.org
767
+ DynamicJsonDocument doc (maxMessageLength);
768
+ DeserializationError error = deserializeJson (doc, response);
769
+ JsonObject obj = doc.as <JsonObject>(); // there is nothing better right now to use obj.containsKey("result")
771
770
closeClient ();
772
771
773
- if (root.success ())
774
- {
775
- if (root.containsKey (" result" ))
776
- {
777
- *file_path = " https://api.telegram.org/file/bot" + _token + " /" + root[" result" ][" file_path" ].as <String>();
778
- *file_size = root[" result" ][" file_size" ].as <long >();
772
+ if (!error) {
773
+ if (obj.containsKey (" result" )) {
774
+ *file_path = " https://api.telegram.org/file/bot" + _token + " /" + obj[" result" ][" file_path" ].as <String>();
775
+ *file_size = obj[" result" ][" file_size" ].as <long >();
779
776
return true ;
780
777
}
781
778
}
You can’t perform that action at this time.
0 commit comments