Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vkontakte API class
<?php
class Vkapi {
protected static $_client_id = 0;
protected static $_access_token = '%access_token%';
public static function invoke ($name, array $params = array())
{
$params['access_token'] = self::$_access_token;
$content = file_get_contents('https://api.vk.com/method/'.$name.'?'.http_build_query($params));
$result = json_decode($content);
return $result->response;
}
public static function auth (array $scopes)
{
header('Content-type: text/html; charset=windows-1251');
echo file_get_contents('http://oauth.vk.com/authorize?'.http_build_query(array(
'client_id' => self::$_client_id,
'scope' => implode(',', $scopes),
'redirect_uri' => 'http://api.vk.com/blank.html',
'display' => 'page',
'response_type' => 'token'
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.