https://oauth.vk.com/authorize?client_id={ID}&scope=wall,photos,audio,video,docs,notes,groups,messages,notifications,stats,ads,notify,friends,offline&redirect_uri=http://oauth.vk.com/blank.html&display=page&response_type=token
#!/usr/bin/env perl use strict; use LWP; use HTTP::Request::Common; my $token = '55e43443343435355a3e70e805722345552227'; # my $gid = '65596688'; # ID . my $file = '/home/ds/test/2.jpg'; # my $site_url = 'http://example.com'; # , my $message = ' '; # .
# getWallUploadServer my $url1 = "https://api.vkontakte.ru/method/photos.getWallUploadServer?gid=$gid&access_token=$token"; my $res_url = &get_data($url1); $res_url =~ s/([\\'])?//g; # . $res_url = $1 if ($res_url =~ m/.*?upload_url\"\:\"(.*?)\".*?/); # URL. my ($url , $param) = split(/\?/, $res_url); # url my %url_param = map {split("=")} split("&", $param);
my $ua = LWP::UserAgent->new (agent=>'Mozilla/5.0', requests_redirectable=>0); my $res = $ua->request ( POST "$url", Content_Type => 'multipart/form-data', Content => [ 'act' => $url_param{'act'}, 'mid' => $url_param{'mid'}, 'aid' => $url_param{'aid'}, 'gid' => $url_param{'gid'}, 'hash' => $url_param{'hash'}, 'rhash' => $url_param{'rhash'}, 'swfupload' => $url_param{'swfupload'}, 'api' => $url_param{'api'}, 'wallphoto' => $url_param{'wallphoto'}, 'photo' => [$file], ], ) die("$!"); my $res_upload = $res->as_string(); $res_upload =~ s/([\\'])?//g; # . # my $server_upload = $1 if ( $res_upload =~ m/server\"\:(.*?),\".*/); my $photo_upload = $1 if ( $res_upload =~ m/\"photo\"\:\"(.*?)\",\"hash.*/); my $hash_upload = $1 if ( $res_upload =~ m/\"hash\"\:\"(.*?)\"}$/);
my $url2 = "https://api.vkontakte.ru/method/photos.saveWallPhoto?gid=$gid&access_token=$token&server=$server_upload&photo=$photo_upload&hash=$hash_upload"; my $res_save = get_data($url2); my $ph_id = $1 if ( $res_save =~ m/\"id\"\:\"(.*?)\",\".*/); #
my $url3 = "https://api.vkontakte.ru/method/"."wall.post?owner_id=-$gid&attachments=$ph_id,$site_url&from_group=1&access_token=$token"; # url . $url3 .="&message=$message" if ($message); # , . my $res_post = get_data($url3);
my $url = shift; my $ua = LWP::UserAgent->new (agent=>'Mozilla/5.0', requests_redirectable=>0); my $get_url = $ua->request (GET "$url") die("$!"); my $res_url = $get_url->as_string(); return ($res_url);
https://api.vkontakte.ru/method/messages.send?uid={UID}&message={MSG}&title={TITLE}&access_token={TOKEN}
https://api.vkontakte.ru/method/status.set?text={TEXT}&access_token={TOKEN}
https://api.vkontakte.ru/method/wall.post?owner_id=-{GID}&message={MSG}&from_group=1&access_token={TOKEN}
Source: https://habr.com/ru/post/211198/
All Articles