I have a telegram bot webhook message like
{
"update_id":236420475,
"message":{
"message_id":26577,
"from":{
"id":xxxxxxxx,
"first_name":"DB",
"last_name":"Ks",
"username":"xxxxxxxx"
},
"chat":{
"id":193044649,
"first_name":"DB",
"last_name":"Ks",
"username":"xxxxxxxx",
"type":"private"
},
"date":1493266832,
"voice":{
"duration":2,
"mime_type":"audio/ogg",
"file_id":"AwADBQADBAADQKMIVC978KStO6ZhAg",
"file_size":7532
}
}
}
From the telegram bot API documentation there is a file_path specified for downloading the file. How can i get the file_path or any API for getting file_path by using file_id?
3
Answers
You should try to do that by getFile method, which returnes a File object. Just get file_path field from File and use it.
It’s simple:
request:
response:
You can download a file in 2 steps:
getFile()
, in response you will be given a response as Alexey Shablowski has shown above where afile_path
is returned with the response valueEx. let’s say, your bot auth token:
1234:abcd
and file_id: ‘xyz890
‘getFile request:
response:
Now get the
file_path
string value and construct your full downloadable link:API detail