Вот тебе готовый мой код.
<?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;
}
?>