Answer the question
In order to leave comments, you need to log in
Download audio message vk api. Does not lose on the mobile version?
Good day, I decided to get to know vk api, namely vk audio api, as you know, VK cut the public VK audio api quite well, leaving only the download, but not everything is so right with it, but not about the usual download now, I stumbled upon it by accident on the topic of tyk there, kind people figured out a little with vk audio api, namely with sending a voice message to PM (download any mp3), did everything as it is written (send on behalf of the group, tried it on behalf of the user. there is the same trouble):
// token - токен группы, vk.token - токен юзера, request-библ xNet
var res = request.Get("https://api.vk.com/method/docs.getWallUploadServer?group_id=<GROUP_ID>&type=audio_message&access_token=" + token+"&v=5.60").ToString();
var link = Pars(res, "upload_url\":\"", "\"", 0).Replace("\\", "");
request.AddFile("file", @namefile);
var s9 = request.Post(link).ToString();
string file = Pars(s9, "file\":\"", "\"", 0);
var ress = request.Get("https://api.vk.com/method/docs.save?file=" + file + "&access_token=" +vk.Token + "&v=5.60").ToString(); //тут токен группы не подходит, иначе даст ошибку тип какойт параметр не верен. приходится использовать токен юзера
string owner = "",id = "";
if (!ress.Contains("captcha"))
{
owner = Pars(ress, "owner_id\":", ",", 0);
id = Pars(ress, "id\":", ",", 0);
}
var res2 = request.Get("https://api.vk.com/method/messages.send?user_id="+ user_id + "&message=" + messag + "&attachment=doc" +owner+"_"+id+"&access_token="+token+ "&v=5.60").ToString();
Answer the question
In order to leave comments, you need to log in
The issue turned out to be the format of the audio file that is sent as audio_message: it must be monophonic in order to play normally on mobile clients.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question