// АВТОПОСТИНГ В ВКОНТАКТЕ НА PHP (vk.com, vkontakte.ru)
$c = curl_init();
$postdata = 'email=ТУТ ЕМЕЙЛ&pass=ТУТ ПАРОЛЬ ОТ НЕГО&act=login&q=&al_frame=1&expire=&captcha_sid=&captcha_key=&from_host=vk.com';
curl_setopt($c, CURLOPT_URL, "vk.com/login.php");
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c,CURLOPT_HTTPHEADER, $h);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_TIMEOUT, 20);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_ENCODING, "");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_exec($c); curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_REFERER, 'http://vk.com/settings');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($c, CURLOPT_URL, 'http://vk.com/');
$r = curl_exec($c);
//регулярками выдераем хеш и айди пользователя
preg_match_all('/"post_hash":"(\w+)"/i', $r, $f1);
preg_match_all('/"user_id":(\d+),/i', $r, $f2);
preg_match_all('/handlePageParams\(\{"id":(\d+),/i', $r, $f3);
$f = array('post_hash'=>$f1[1][0], 'my_id'=>$f3[1][0]);
$url = urlencode(mb_convert_encoding("http://gloys.ru",'UTF-8','windows-1251'));
$mess = urlencode(mb_convert_encoding("Текст сообщения",'UTF-8','windows-1251'));
$title = urlencode(mb_convert_encoding("Заголовок сообщения",'UTF-8','windows-1251'));
$desc = urlencode(mb_convert_encoding("Описание",'UTF-8','windows-1251'));
$postdata = 'act=post&al=1&hash='.$f['post_hash'].'&message='.$mess.'&to_id='.$f['my_id'].'&type=all&url='.$url.'&title='.$title.'&description='.$desc;
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_HTTPHEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_REFERER, 'http://vk.com/id'.$f['my_id']);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($c, CURLOPT_TIMEOUT, 20);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($c, CURLOPT_URL, 'http://vk.com/al_wall.php');
$r = curl_exec($c);
echo $r;curl_close($c);
$c = curl_init();
$postdata = 'email=ТУТ ЕМЕЙЛ&pass=ТУТ ПАРОЛЬ ОТ НЕГО&act=login&q=&al_frame=1&expire=&captcha_sid=&captcha_key=&from_host=vk.com';
curl_setopt($c, CURLOPT_URL, "vk.com/login.php");
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c,CURLOPT_HTTPHEADER, $h);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_TIMEOUT, 20);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_ENCODING, "");
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_exec($c); curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_REFERER, 'http://vk.com/settings');
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($c, CURLOPT_URL, 'http://vk.com/');
$r = curl_exec($c);
//регулярками выдераем хеш и айди пользователя
preg_match_all('/"post_hash":"(\w+)"/i', $r, $f1);
preg_match_all('/"user_id":(\d+),/i', $r, $f2);
preg_match_all('/handlePageParams\(\{"id":(\d+),/i', $r, $f3);
$f = array('post_hash'=>$f1[1][0], 'my_id'=>$f3[1][0]);
$url = urlencode(mb_convert_encoding("http://gloys.ru",'UTF-8','windows-1251'));
$mess = urlencode(mb_convert_encoding("Текст сообщения",'UTF-8','windows-1251'));
$title = urlencode(mb_convert_encoding("Заголовок сообщения",'UTF-8','windows-1251'));
$desc = urlencode(mb_convert_encoding("Описание",'UTF-8','windows-1251'));
$postdata = 'act=post&al=1&hash='.$f['post_hash'].'&message='.$mess.'&to_id='.$f['my_id'].'&type=all&url='.$url.'&title='.$title.'&description='.$desc;
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_HTTPHEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_REFERER, 'http://vk.com/id'.$f['my_id']);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_USERAGENT, $uagent);
curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($c, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($c, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($c, CURLOPT_TIMEOUT, 20);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($c, CURLOPT_URL, 'http://vk.com/al_wall.php');
$r = curl_exec($c);
echo $r;curl_close($c);