Skip to content

Instantly share code, notes, and snippets.

@alright
Last active September 30, 2015 01:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alright/1698905 to your computer and use it in GitHub Desktop.
Save alright/1698905 to your computer and use it in GitHub Desktop.
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