The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

VK::OAuth - OAuth authorization on your site with VK API

SYNOPSIS

  my $vk = VK::OAuth->new(
      app_id     => 'YOUR APP ID',
      secret     => 'YOUR APP SECRET',
      postback   => 'POSTBACK URL',
  );
  my $url = $vk->authorize( {option => 'value'} );
  # Your web app redirect method.
  $self->redirect($url);
  # Get access_token.
  my $access = $vk->request_access_token($args->{code});
  # Get user profile data.
  my $profile_data = $vk->request(
      'users.get',
      $access_token,
      {
            fields => "uid,first_name,last_name,nickname,screen_name,sex,bdate,city,country",
        uids   => $user_id,
      }
  );  

DESCRIPTION

Use this module for input VK OAuth authorization on your site

METHODS

new

  my $vk = VK::OAuth->new(
      app_id     => 'YOUR APP ID',
      secret     => 'YOUR APP SECRET',
      postback   => 'POSTBACK URL',
  );

The new constructor lets you create a new VK::OAuth object.

authorize

        my $url = $vk->authorize( {option => 'value'} );
        # Your web app redirect method.
        $self->redirect($url);

This method returns a URL, for which you want to redirect the user.

Options

See information about options on http://vk.com/developers.php

Response

Method returns URI object.

request_access_token

  my $access = $vk->request_access_token($args->{code});

This method gets access token from VK API.

Options

code - returned in redirected get request from authorize API method.

Response

Method returns HASH object with keys $obj->{user_id}, $obj->{access_token}, $obj->{expires_in}.

request

  my $profile_data = $vk->request(
      'users.get',
      $access_token,
      {
            fields => "uid,first_name,last_name,nickname,screen_name,sex,bdate,city,country",
        uids   => $user_id,
      }
  );

This method sends requests to VK API.

Options

method (required) - returned in redirected get request from authorize API method; params (not required) - other params; access_token (required) - access token.

Response

Method returns HASH object with requested data.

SUPPORT

Github: https://github.com/Foxcool/VK-OAuth

More information: http://vk.com/developers.php

AUTHOR

Copyright 2012 Alexander Babenko.