++ed by:

1 non-PAUSE user.

Misha Genaev
and 1 contributors

NAME

VK::App - Creation of a client application for vk.com

SYNOPSIS

    ### Application object creation ###
    #1. Authorizing by login and password
    use VK::App;
    my $vk = VK::App->new(
            # Your email or mobile phone to vk.com    
            login => 'login',
            # Your password to vk.com
            password => 'password',
            # The api_id of application
            api_id => 'api_id',
            # Name of the file to restore cookies from and save cookies to
            #(this parameter is optional in this case)
            cookie_file => '/home/user/.vk.com.cookie',
    );

    #2. Authorizing by cookie file
    use VK::App;
    my $vk = VK::App->new(
            # Name of the file to restore cookies from and save cookies to
            cookie_file => '/home/user/.vk.com.cookie',
            # The api_id of application
            api_id => 'api_id',
    );

    #3. Set additional options
    use VK::App;
    my $vk = VK::App->new(
            # Name of the file to restore cookies from and save cookies to
            cookie_file => '/home/user/.vk.com.cookie',
            # The api_id of application
            api_id => 'api_id',
            # Set application access rights
            scope => 'friends,photos,audio,video,wall,groups,messages,offline',
            # Data format that will receive as a result of requests 'JSON', 'XML' or 'Perl'.
            # Perl object by default.
            format => 'Perl',
    );
            
    ### Requests examples ###

    #1. Get user id by name
    my $user = $vk->request('getProfiles',{uid=>'genaev',fields=>'uid'});
    my $uid = $user->{response}->[0]->{uid};

    #2. Get a list of tracks by uid
    my $tracks = $vk->request('audio.get',{uid=>$uid});
    my $url = $tracks->{response}->[0]->{url}; # get url of the first track

DESCRIPTION

VK::App - Module for creation of client applications based on OAuth 2.0, receiving access rights and sending requests to API vk.com. First, you need to get api_id application that will work with the API of vk.com. You can register your application at http://vk.com/apps.php?act=add or use api_id of the existing application.

This package also includes scripts/vmd.pl script, that shows how to use the module.

METHODS

new

Creates and returns an VK::App object. Takes a list containing key-value pairs.

  • Required Arguments

    • api_id

      The api_id of application. You can register your application at https://vk.com/editapp?act=create or use api_id of the existing application.

    • login

      Your email or mobile phone to vk.com

    • password

      Your password to vk.com

    • cookie_file

      Name of the file to restore cookies from and save cookies to. Notice that instead of a login and password, you can only use the file cookie_file!

  • Other Important Arguments

    • scope

      Set application access rights. List of available access rights http://vk.com/dev/permissions. 'friends,photos,audio,video,wall,groups,messages,offline' by default.

    • format

      Data format that will receive as a result of requests 'JSON', 'XML' or 'Perl'. Perl object by default.

request

Send requests and return response.

    my $response = $vk->request($METHOD_NAME,$PARAMETERS);

API method description available at http://vk.com/dev/methods

ua

Returns LWP::UserAgent object. This can be useful for downloading music, videos or photos from vk.com. See scripts/vmd.pl script that is included in the package.

uid

Returns UID of the current user.

access_token

Returns access_token. access_token - access key received as a result of successful application authorization.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc VK::App

If you have any questions or suggestions please contact me by email.

AUTHOR

Misha Genaev, <mag at cpan.org> (http://genaev.com/)

COPYRIGHT

Copyright 2012-2014 by Misha Genaev

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.