Your IP : 172.28.240.42


Current Path : /var/www/html/clients/e-nkama.ru/e-nkama_bitrix/cron/
Upload File :
Current File : /var/www/html/clients/e-nkama.ru/e-nkama_bitrix/cron/vkonline.php

<?
//http://api.vkontakte.ru/blank.html#access_token=646c15a4cdc1f4d44155b5b7e6c52aa34440e1b8df656f52ea1c6286a1985fe8ff48458fd83b4a08c9dfe&expires_in=0&user_id=313054269
//https://oauth.vk.com/authorize?client_id=3087106&scope=photos,audio,video,wall,groups,offline,stats&redirect_uri=http://api.vkontakte.ru/blank.html&display=page&response_type=token

function api($method, $param) { 
	$getApi = file_get_contents('https://api.vk.com/method/'.$method.'?'.$param); 
	return json_decode($getApi, true); 
} 

$token = '847accc5798391c043915bb3939eaf255a4dfce1df9fd0e748a2a6baf531f17d28ad7e97c3fd14f24e430'; // Access token ïîëó÷èòü òóò http://vk.cc/1ihg6R 

//ïîìå÷àåì îíëàéí
$response = api('account.setOnline', 'access_token='.$token); 
echo "<br/><b>----Îíëàéí----</b><br/>";
print_r($response);

if(rand(1, 7)==5 || isset($_GET['start_all'])){
	//ïîëó÷àåì ñïèñîê ñîîáùåíèé
	echo "<br/><b>----Ïîìå÷àåì ñîîáùåíèÿ ïðî÷èòàííûìè----</b><br/>";
	$messages  = api('messages.get', 'filters=1&count=200&access_token='.$token); 
	foreach ($messages['response'] as $key => $mes) {
		if($mes['mid']){
			$mess_arr[] = $mes['mid'];
		}
	}

	//ïîìå÷àåì êàê ïðî÷èòàííûå
	if(count($mess_arr)>1){
		$response = api('messages.markAsRead', 'message_ids='.implode(",", $mess_arr).'&access_token='.$token); 
		print_r($response);
	}
}

if(rand(1, 20)==5 || isset($_GET['start_all'])){
	//ñïèñîê äðóçåé
	echo "<br/><b>----Óäàëÿåì çàáëîêèðâàííûõ äðóçåé----</b><br/>";
	$friends   = api('friends.get', 'order=random&fields=friend_status,deactivated&access_token='.$token); 
	//âûáèðàåì òîëüêî çàáëîêèðîâàííûõ è óäàëÿåì
	foreach ($friends['response'] as $key => $friend) {
		if(isset($friend['deactivated'])){
			$response = api('friends.delete', 'user_id='.$friend["user_id"].'&access_token='.$token); 
			print_r($response);
		}
	}

	//ïîëó÷àåì ñïèñîê âûñëàííûõ çàÿâîê è óäàëÿåì èõ
	echo "<br/><b>----Óäàëÿåì âûñëàííûå çàÿâêè----</b><br/>";
	$subscribe_out = api('friends.getRequests', 'out=1&access_token='.$token);
	if(isset($subscribe_out['response'])){
		foreach ($subscribe_out['response'] as $key => $friend) {
			$response = api('friends.delete', 'user_id='.$friend.'&access_token='.$token); 
			print_r($response);
		}
	}

	//ïîëó÷àåì çàÿâêè â äðóçüÿ
	echo "<br/><b>----Äîáàâëÿåì â äðóçüÿ----</b><br/>";
	$frnd_cnt  = api('friends.get', '&access_token='.$token);//òåêóùåå êîë-âî äðóçåé 
	$get_cnt = 10000-count($frnd_cnt['response']);
	if($get_cnt>10 && $get_cnt<100){
		$subscribe_in = api('friends.getRequests', 'out=0&sort=1&count='.$get_cnt.'&access_token='.$token);
		foreach ($subscribe_in['response'] as $key => $friend) {
			$response = api('friends.add', 'user_id='.$friend.'&access_token='.$token);
			print_r($response);
		}
	}
}

?>