Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class VK {
- static $predefined_params;
- public static function init ($predefined_params) {
- self::$predefined_params = $predefined_params;
- }
- public static function api ($method, $params) {
- $params = array_merge(self::$predefined_params, $params);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://api.vk.com/method/{$method}");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
- $response_raw = curl_exec($ch);
- curl_close($ch);
- $response = json_decode($response_raw, TRUE);
- return $response;
- }
- }
- // example
- VK::init(array(
- 'access_token' => $_GET['access_token'],
- 'https' => 1,
- 'v' => '5.24',
- ));
- $response = VK::api("audio.get", array('owner_id' => $_GET['viewer_id']));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement