Last active
September 30, 2015 01:18
-
-
Save alright/1698905 to your computer and use it in GitHub Desktop.
Vkontakte API class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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