-
-
Save khadorkin/11175646 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* message - сообщение, которое будет опубликовано | |
* image - картинка для постинга | |
* user_id - id текущего пользователя (к нему будет осуществлён постинг) | |
*/ | |
function wallPost(message, image, user_id) { | |
VK.api('photos.getWallUploadServer', { | |
uid: user_id | |
}, function (data) { | |
if (data.response) { | |
$.post('/upload/', { // url на ВАШЕМ сервере, который будет загружать изображение на сервер контакта (upload_url) | |
upload_url: data.response.upload_url, | |
image: image, | |
}, function (json) { | |
VK.api("photos.saveWallPhoto", { | |
server: json.server, | |
photo: json.photo, | |
hash: json.hash, | |
uid: user_id | |
}, function (data) { | |
VK.api('wall.post', { | |
message: message, | |
attachments: data.response['0'].id | |
}); | |
}); | |
}, 'json'); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment