Trying to make a post on the wall vk (text message and photo). To do this, upload a photo to the user's wall. I do documentation:
Using the photos.getWallUploadServer method, the application recognizes the http address for uploading a photo to the wall of the current user, another user or group, depending on the passed parameters user_id or group_id.
var url = 'https://api.vk.com/method/photos.getWallUploadServer?gid=' + Ti.App.Properties.getString('vk_user_id') + '&access_token=' + Ti.App.Properties.getString('vk_access_token');Then I make a request
client.open('GET', url); client.send();Comes the http-address to upload photos on the wall of the current user.
Next I want to upload a photo. The application forms a POST request to the received address. The request must include a photo field containing an image file (jpg, png, bmp or gif)
var client_2 = Ti.Network.createHTTPClient({ onload: function() { alert(this.responseText); }, onerror: function(e) { modalWindows.createAlert(e.error); }, timeout: 5000 }); client_2.open('POST', resUrl); //resUrl http-адрес client_2.setRequestHeader('enctype', 'multipart/form-data'); client_2.send({photo: $.walkPhoto.getImage()});
As a result, the answer comes
{"server": "622930", "photo": "[]", "hash": "12345abcde"}
I do not know why the photo comes as an empty array.