M
M
mumus2017-01-12 17:44:53
JavaScript
mumus, 2017-01-12 17:44:53

Discount for reposting through the site?

Is it possible to make it so that when adding a certain post to the wall, give the user some kind of discount? I followed the example:

$('.getbonus').on('click', function(){
                if (!$(this).hasClass('disabled')){
                    var message = $(this).attr("data-message");
                    hClick(message);
                }
            })

            function hClick(message) { // обработчик нажатия
                VK.Api.call('wall.post', {
                    message:message,
                    attachments:"https://site.ru"
                }, hPost); 
            }

            function hPost(r) { // обработчик окончания выполнения API запроса
                if(!r) throw "Bad response from VK";
                if( r.error) { // если отказался постить
                    console.log("Not posted. Error:", r.error);
                } else if( r.response) {
                    if( r.response.post_id) { // это id свежесозданного поста
                        console.log("Posted with id ", r.response.post_id);
                        console.log("Скидка получена", r.id);
                    } else {
                        console.log("No post id, no idea why", r);
                    }
                } else {
                    console.log("Not posted, no idea why", r);
                }
            }

But this only works for me, apparently for the owner of the group, etc. Is it possible to make any user be able to repost?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2017-01-12
@bingo347

https://vk.com/dev/share_details
https://vk.com/dev/objects/post
To read the wall, you need to authorize the user through vk with the appropriate permissions, since you need to know the user uid
https://vk.com/ dev/access_token

M
Maxim Timofeev, 2017-01-12
@webinar

Simple option: Add a parameter to the link, and give a discount on the first transition from the repost to the site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question