Answer the question
In order to leave comments, you need to log in
vk API. How to upload photos in a private message?
I'm trying, I mean, upload a photo to the VK dialog, I use the Vk.Net library for C # for this
var imageFile = "C:\\имя_картинки.jpeg"
var uploadServer = api.Photo.GetMessagesUploadServer(); //Получаем ссылку на сервер для загрузок
var uploadServerUri = uploadServer.UploadUrl;
var uploader = new WebClient();
var uploadResponseInBytes = uploader.UploadFile(uploadServerUri, imageFile); // Загружаем фото на сервер
var uploadResponseInString = Encoding.UTF8.GetString(uploadResponseInBytes);
var jsonObject = (JObject)JsonConvert.DeserializeObject(uploadResponseInString);
var photoParameter = jsonObject["photo"].ToString(); // вынимаем photo из ответа (исп. Newtonsoft.json)
[{"photo":"49c64fbb0a:w","sizes":,"kid":"92e5a11b70f880ac622c7fea7f5aba7c","debug":"xswmwxwywzwwwowpwqwrw"}]
var photo = api.Photo.SaveMessagesPhoto(photoParameter);
error: {
error_code: 118,
error_msg: 'Invalid server',
request_params: [{
key: 'oauth',
value: '1'
}, {
key: 'method',
value: 'photos.saveMessagesPhoto'
}, {
key: 'photo',
value: '[{"photo":"49c64fbb0a:w","sizes":[["s","629526621","21260","6Jkf9T9YZjE",58,75],["m","629526621" ,"21261","4YmH_tNjSBc",100,130],["x","629526621","21262","LvxGnkaZwL8",464,604],["y","629526621","21263","O21xjup4jp4",620,807 ],["z","629526621","21264","v2kvn2V540o",830,1080],["w","629526621","21265","v76d9glIcJo",922,1200],["o" ,"629526621","21266","ihP89qpXY1E",130,169],["p","629526621","21267","i1SUBQRgNtM",200,260],["q","629526621","21268","
{
key: 'v',
value: '5.40'
}]
}
Answer the question
In order to leave comments, you need to log in
...
error_code: 118,
error_msg: 'Invalid server',
var uploadServerUri = uploadServer.upload_url;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question