Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- sendVk("опаопа");
- function sendVK($message) {
- $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.2.13) ' .
- 'Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729)';
- $cookie = '';
- $login = 'my_login'; // изменить
- $password = 'my_pass'; //
- $group_page = 'http://vk.com/my_page'; //
- /**
- * Логинимся
- */
- $answer = auth($login, $password);
- /**
- * Получаем ид сессии и куки
- */
- $sid = substr($answer, strpos($answer, "setCookieEx('sid', '") + 20, 60);
- $cookie = 'remixsid=' . $sid;
- /**
- * Получаем страницу
- */
- $page = getPage($group_page, $cookie);
- sendPost($page,$message, $cookie);
- }
- function sendPost($page, $message, $cookie) {
- $post_hash = substr($page, strpos($page, '"post_hash":"') + 13, 18);
- $group_id = substr($page, strpos($page, '"group_id":') + 11, 7);
- $ch = curl_init();
- $fields = "act=post&al=1&hash={$post_hash}&message={$message}&to_id=-{$group_id}&type=all&official=1";
- curl_setopt($ch, CURLOPT_COOKIE, $cookie);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
- curl_setopt($ch, CURLOPT_URL, 'http://vk.com/al_wall.php');
- ob_start();
- $answer = curl_exec($ch);
- ob_end_clean();
- }
- function auth($login, $password) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_URL, 'http://login.vk.com/?act=login');
- $post = array(
- 'act' => 'login',
- 'q' => '',
- 'al_frame' => '1',
- 'expire' => '',
- 'captcha_sid' => '',
- 'captcha_key' => '',
- 'from_host' => 'vkontakte.ru',
- 'email' => $login,
- 'pass' => $password
- );
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
- $answer = curl_exec($ch);
- return $answer;
- }
- function getPage($url, $cookie) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_COOKIE, $cookie);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- ob_start();
- curl_exec($ch);
- $answer = ob_get_contents();
- ob_end_clean();
- return $answer;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement