Lightweight vk.com library based on Zend Framework 1
PHP HTML
Failed to load latest commit information.
src e-mail is stored from now on Nov 3, 2015
.gitignore VK method is changed, closes #2 Oct 30, 2015
README.md e-mail is stored from now on Nov 3, 2015

README.md

Examples

Constructor

<?php
// see: _misc/singleton.php

require_once 'Other/Vkontakte/Api.php';

$config = Zend_Registry::get('config')->vk;
$authUri = 'http://mysite.com/vk';

$api = new \Vkontakte\Api(
    $config->id, $config->key, $authUri,
    array('offline', 'notes', 'wall')
);

Auth

<?php
// the api object
$api = MyProject_Social_Vkontakte::getInstance();

// we haven't error, closing and forward
if (!$this->hasParam('error')) {
    if ($api->authorize($this->getParam('code'))) {
        // see: _misc/controller.php
    }
}

Access to the storage object

// auth process...
$api->getStorage()->getUserId();
$api->getStorage()->getExpiresIn();
$api->getStorage()->getAccessToken();
$api->getStorage()->getEmail();

Controller

<?php
$api = MyProject_Social_Vkontakte::getInstance();

$attrs = array(
    'user_ids' => $api->getUid(),
    'fields' => 'country,city,contacts,notes'
);

// users.get
var_dump($api->usersGet($attrs));

// places.getCityById
var_dump($api->databaseGetCitiesById(array('city_ids' => 123)));

// notes.add
$response = $api->notesAdd(array(
    'title' => 'Buy milk',
    'text' => 'Otherwise she kills me :('
));

var_dump($response);

Method structure

@see: https://vk.com/dev/methods
$api->databaseGetCitiesById = database.getCitiesById
$api->authCheckPhone = auth.checkPhone
$api->usersGet = users.get
etc...

Template

<-- socialLogin class opens popup window -->
<a href="<?=$this->vk()->uri('/my/link')?>"<?=$this->vk()->uid() ? '' : ' class="socialLogin"'?>>Link</a>

VK Setup