Немного попыхтел и написал скрипт. Описалово! Скрипт публикует на стенке фотку-ссылку с альбома. В результате она доступна в новостях для друзей. Может публиковать рандомную фотографию с альбома сообщества, с обычного альбома с публичной страницы. PHP: <? $login = 'some@email'; $password = 'somepass'; $id_account = '123456'; $user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 WebMoney Advisor'; $main_url = 'http://vk.com/'; $albums = array ( 0 =>'album-12345678_123456789', ); /* Begin body script */ // get cookie for some account for next http request $cookie = get_gookie(); // debug //echo debug(); // Get photo from some not empty album $photos = get_photos( $albums[0] ); // Publication on the wall, second param when photo from community publication_wall( $photos, 1 ); /** * Get cookie for some account * @return string */ function get_gookie() { global $main_url, $user_agent, $login, $password; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 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' => $main_url, 'email' => $login, 'pass' => $password, ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); $answer = curl_exec($ch); $sid = substr($answer, strpos($answer, "setCookieEx('sid', '") + 20, 60); $cookie = 'remixsid=' . $sid; return $cookie; } /** * Debug login * @return string Content */ function debug() { global $main_url, $cookie, $user_agent; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $main_url); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); return $result; } /** * Get photos from Album * @param string $name_album Some album * @return array Photos from Album */ function get_photos( $name_album ) { global $main_url, $cookie, $user_agent, $post_hash; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, trim($main_url, '/') . '/' . $name_album); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); // [-]{0,1} may be album in some group or some profile preg_match_all('@<div class="photo_row" id="photo_row[-]{0,1}([\d_]+)">@', $result, $photos); $photos = $photos[1]; // get post_hash string what need for publication on wall preg_match ("@post_hash: '([\da-z]+)',@", $result, $post_hash); $post_hash = $post_hash[1]; // photos not found if (! count($photos) ) die; return $photos; } /** * Publication on the wall * @param array $photos Array photos from some albums * @param bool group If true use "-" in community */ function publication_wall( $photos, $group = 0 ) { global $main_url, $cookie, $user_agent, $id_account, $post_hash; // get random photo $some_photo = mt_rand( 0, count($photos) - 1 ); // if foto is located in community if ( $group ) $photos[$some_photo] = '-' . $photos[$some_photo]; // not publish when photo not found if (! $photos[$some_photo] ) die(); // save draft $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, trim($main_url, '/') . '/' . 'al_wall.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Requested-With: XMLHttpRequest', 'Referer: http://vk.com/feed', ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $post = array( 'act' => 'save_draft', 'al' => 1, 'hash' => $post_hash, 'media1' => 'photo|' . $photos[$some_photo], 'msg' => 'http://vk.com/photo' . $photos[$some_photo], // others message ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); $result = curl_exec($ch); // publish photo $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, trim($main_url, '/') . '/' . 'al_wall.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Requested-With: XMLHttpRequest', 'Referer: http://vk.com/feed', ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $photo_first_part is id for account list($photo_first_part, $phot_second_part ) = explode('_', $photos[$some_photo]); // delete - before id for some account if ($group) $photo_first_part = trim($photo_first_part, '-'); $post = array( 'act' => 'post', 'al' => 1, 'attach1' => $photos[$some_photo], 'attach1_type' => 'photo', 'facebook_export' => '', 'friends_only' => '', 'hash' => $post_hash, 'message' => 'http://vk.com/photo' . $photos[$some_photo], // here our message for photo 'note_title' => '', 'official' => '', 'signed' => '', 'status_export' => '', 'to_id' => $id_account, 'type' => 'all', ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); $result = curl_exec($ch); }
Вот вы значит чем в приватах занимаетесь Возможно, я оглашу слишком очевидную проблему, но все-же. Может это проблема с тем, что сервер, с которого выполняется скрипт, имеет ip страны, из которой обычно не заходят на данный аккаунт?