2
2
2gaap2017-04-13 09:58:27
PHP
2gaap, 2017-04-13 09:58:27

How to automatically delete a post from the wall of a VKontakte group if a repost is not made (spam protection)?

There is an open VKontakte group, spam constantly goes to the wall and it is not the job of a programmer to delete it manually.
How to write a script in php so that it automatically deletes posts if, for example, the user has not reposted a certain post.
(it is understood that bots are not yet able to repost entries and such spam protection should show itself well + advertising of the group).
Wouldn't such a condition be a violation of the VKontakte rules?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2gaap, 2017-04-13
@2gaap

Based on this - www.bubasik.com/skript-php-dlya-vkontakta-avto-uda...
I did this:
- Callback from the group about a new post
- The user id of the new post is taken and it is checked whether he reposted the post (which you need to repost) by wall.getReposts
- If you didn’t do it, a comment is written to his post and after a few seconds the post is deleted.

$ch_search_vk = curl_init( "https://api.vk.com/method/wall.getReposts?owner_id=-номер_группы&v=5.0&count=100&post_id=номер_поста_который_должны_репостнуть" );
              curl_setopt ( $ch_search_vk, CURLOPT_HEADER, false );
              curl_setopt ( $ch_search_vk, CURLOPT_RETURNTRANSFER, true );
              curl_setopt ( $ch_search_vk, CURLOPT_SSL_VERIFYPEER, false );
              $search_vk = curl_exec($ch_search_vk);
              curl_close($ch_search_vk);
              $search_vk=json_decode($search_vk);
              
$search_result_massiv = $search_vk->response->items;

$count_massiv = count($search_result_massiv);

//перебираем массив
    for ($i=0; $i<$count_massiv; $i++)
        {
        if ($search_result_massiv[$i]->from_id == $user_id) {
            //нашли совпадение
            $search_result="1";
            $log_text = "$today ok - search_result = $search_result, user id = $user_id, $text_post";
            }
        }

I made an addition that checks for a repost of a given entry, if there is no repost, then a comment is written on behalf of the group to the user's post and then after 9 seconds the user's post is deleted. Code here - https://pastebin.com/KjbTd1kz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question