Answer the question
In order to leave comments, you need to log in
VK API Delete script who unsubscribed.?
Why is the script not working, what am I doing wrong?
<?php
$access_token = 'ТУТ МОЙ ТОКЕН';
$v = 'v=3.0';
print_r ($v);
$rf = curl("https://api.vk.com/method/friends.getRequests?out=1&access_token=$access_token&$v");//проверка тех кто удалил
sleep(1);
$json2 = json_decode($rf,1);
$rfj = $json2['response'];
$count=count($rfj);//считаем сколько нас удалило
$id=$rfj;
for($r=0; $r<$count; $r++){
sleep(0);//???????? 2 ???
curl("https://api.vk.com/method/friends.delete?user_id=$id[$r]&access_token=$access_token&$v"); //отписываемся
sleep(0);//???????? 1 ???
curl("https://api.vk.com/method/account.banUser?user_id=$id[$r]&access_token=$access_token&$v");//добавляем в чёрный список
}
function curl($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, "Opera/10.00 (Windows NT 5.1; U; ru) Presto/2.2.0");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response=curl_exec($curl);
curl_close($curl);
return $response;
}
?>
Answer the question
In order to leave comments, you need to log in
Here is my finished code.
<?php
$access_token = '';
$get = curl('https://api.vk.com/method/friends.getRequests?out=1&count=1&v=5.60&access_token='.$access_token);
$json = json_decode($get,1);
$check = $json['response']['count'];
if($check == 0) {
die ('Исходящих зявок нет.');
}
$id = $json['response']['items']['0'];
$del = curl('https://api.vk.com/method/friends.delete?user_id='.$id.'&v=5.60&access_token='.$access_token);
$ifjson = json_decode($del,1);
$ok = $ifjson['response']['out_request_deleted'];
if($ok == 1) {
echo 'Отписался от ID'.$id.'.';
}
addlog("<a href='https://vk.com/id$id'>$id</a>");
function addlog($logtext){
$fp = fopen( './del.html', 'a' );
fwrite( $fp, '<br>['.date( 'd.m.Y H:i:s', time() ).'] '.$logtext.PHP_EOL);
}
function curl($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
<?php
$access_token = '';
$get = curl('https://api.vk.com/method/friends.getRequests?out=1&count=1&v=5.60&access_token='.$access_token);
$json = json_decode($get,1);
$check = $json['response']['count'];
if($check == 0) {
die();
}
$id = $json['response']['items']['0'];
$del = curl('https://api.vk.com/method/friends.delete?user_id='.$id.'&v=5.60&access_token='.$access_token);
$ifjson = json_decode($del,1);
$ok = $ifjson['response']['out_request_deleted'];
function curl($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question