H
H
hr_lolka2017-04-03 23:16:20
In contact with
hr_lolka, 2017-04-03 23:16:20

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();

As a result, audio is sent to the LAN, everything would be fine, but it doesn’t load from the mobile version, everything is fine from the PC, but you can’t listen to it from the mobile version, personally, on WP, when you turn on the audio recording, it takes 1 second from the beginning to the end of the track without making any noise (and even more so the music itself), the same trouble with other phones. Maybe someone met? Or at least have some advice? I will be grateful for any help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-04-05
@hr_lolka

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 question

Ask a Question

731 491 924 answers to any question