📜 ⬆️ ⬇️

VK :: App - a module for creating client applications in vk.com

I want to tell you about my VK :: App module for creating client applications in the vk.com social network. The main features of the module:
The module uses a minimum of dependencies: only LWP and JSON.

To write a client application, you need to know api_id . To do this, you can register your application or use the existing api_id .

Syntax


Constructors

#1.      use VK::App; my $vk = VK::App->new( #     email login => 'login', #  password => 'password', # api_id  api_id => 'api_id', #         cookies #(       ) cookie_file => '/home/user/.vk.com.cookie', ); #2.    cookies  use VK::App; my $vk = VK::App->new( cookie_file => '/home/user/.vk.com.cookie', api_id => 'api_id', ); #3.   use VK::App; my $vk = VK::App->new( cookie_file => '/home/user/.vk.com.cookie', api_id => 'api_id', #    ,    . #         : # http://vk.com/developers.php?oid=-17680044&p=Application_Access_Rights scope => 'friends,photos,audio,video,wall,groups,messages,offline', #         : # 'JSON', 'XML'  'Perl' .   : 'Perl'. format => 'Perl', ); 

Query examples

  #  : # my $response = $vk->request($METHOD_NAME,$PARAMETERS); #   : # http://vk.com/developers.php?oid=-17680044&p=API_Method_Description #1.  uid     my $user = $vk->request('getProfiles',{uid=>'genaev',fields=>'uid'}); my $uid = $user->{response}->[0]->{uid}; #2.       uid my $tracks = $vk->request('audio.get',{uid=>$uid}); my $url = $tracks->{response}->[0]->{url}; #    mp3   


The module is published on cpan. More detailed documentation and description of all methods: https://metacpan.org/module/VK::App .
')

Why do you need another bike?


Because other bikes have square wheels! I have a few favorite music bands and friends with our musical tastes in vk.com. I wanted to have an up-to-date local copy of the music of these groups and friends, in order to listen to it, for example, in a car. those. be able to auto sync. I did not consider applications with GUI in principle. Among the console did not find suitable. It would be possible to look for an implementation of the API for other programming languages ​​(I have experience with Ruby, Python, Java, C), but the soul lies precisely with Perl. On cpan.org there are two modules VK :: MP3 and VKontakte :: API. VK :: MP3 is a normal module, but it does not solve my problems, because deals only with the search for music. VKontakte :: API is absolutely not workable. First, for some reason, it requires the application's secret key, which is unsafe. Secondly, the request getUserSettings returns the code +1, which means the actual absence of access rights . Thirdly, when using the third version of the constructor, the module simply drops. For these reasons, the idea of ​​writing the module, which is discussed here, arose.

Plans


Bring to mind my vmd program (vkontakte music downloader) for which everything was started. Put it on github, maybe it will be useful to someone? I can build static binaries from a program under windows, mac, linux (there is a purchased version of PDK).

It so happened that VK :: App is my first module published on CPAN. And the publication process took two to three times more time than writing the module itself. It seems to be a lot of information on the network, but you do not know a clear sequence of actions. Yes, and there are pitfalls. I studied this question in some detail and wrote instructions for myself on how to correctly and quickly build a distribution kit of a module for its publication. I can comb it a little and post it as a separate article on habrahabr.

I will be glad to any fitbekam!

UPD
about the plans:
post about vkontakte music downloader - habrahabr.ru/post/146889
post about the publication of modules - habrahabr.ru/post/146821
In addition, vk.com changed the authorization mechanism by login and password and had to change the module. The current version of VK :: App 0.06 is working, all previous ones do not work. I suspect that the VK :: MP3 module has also stopped working.

Source: https://habr.com/ru/post/146598/


All Articles