Постоянный статус онлайн ВКонтакте

Для того, чтобы быть всегда онлайн ВКонтакте, понадобятся следующие ингредиенты:

  • PHP-хостинг с поддержкой CURL и возможностью настроить CRON
  • Standalone-приложение VK (создать)
  • Аккаунт в antigate.com с положительным балансом (иногда вылезает каптча)

Для начала нужно разрешить приложению использовать наш аккаунт. Это можно сделать по ссылке: https://oauth.vk.com/authorize?client_id=3494376&redirecturi=api.vk.com/blank.html&scope=wall,status,offline&display=page&response_type=token, где clientid - ID нашего приложения. После успешной авторизации нужно скопировать access_token из адресной строки в код ниже, в переменную $token. Скрипт, представленный ниже, необходимо поместить в директорию с правами на запись (777).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$token = ''; // access_token
$antigate_key = ''; // http://antigate.com/panel.php?action=showkey
$online = api('account.setOnline', 'access_token='.$token); // продлеваем online на 15 минут
if (isset($online["error"]["captcha_img"])) {
$img_captcha = $online["error"]["captcha_img"];
$captcha_sid = $online["error"]["captcha_sid"];
$antigate_response = antigate($antigate_key, $img_captcha);
$online = api('status.set', 'access_token='.$token.'&captcha_sid='.$captcha_sid.'&captcha_key='.$antigate_response);
}


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


function antigate($key, $captcha) {
$captcha_path = 'captcha.jpg';
file_put_contents($captcha_path, file_get_contents( $captcha ) );
$postdata = array(
'method' => 'post',
'is_russian' => '1',
'key' => $key,
'file' => '@captcha.jpg',
);
while (true) {
$getId = curler('http://antigate.com/in.php', null, $postdata);
if (strstr($getId, 'ERROR')) {
$res = false;
break;
} else {
$captchaId = str_replace('OK|', '', $getId);
sleep(2);
while (true) {
$getText = curler('http://antigate.com/res.php?key='.$key.'&action=get&id='.$captchaId);
if (strstr('CAPCHA_NOT_READY', $getText)) {
continue;
} elseif ($res = str_replace('OK|', '', $getText)) {
break;
}
}
break;
}
}
unlink($captcha_path);
return $res;
}


function curler($url, $cookie = null, $post = null) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if (isset($cookie)) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if (isset($post)) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$response = curl_exec($ch);
curl_close($ch);
return $response;
}

Теперь остается лишь поставить скрипт на 15-ти минутный CRON и ваш аккаунт будет постоянно онлайн ВКонтакте. Поздравляю, теперь Вы будете онлайн ВКонтакте круглосуточно!