Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class VK {
- private $token;
- private $v;
- const URL = 'https://api.vk.com/method/';
- public function __construct($token, $v = '5.69') {
- $this->token = $token;
- $this->v = $v;
- }
- public function api($method, $params = array(), $obj = false) {
- if(!array_key_exists('access_token', $params)) $params['access_token'] = $this->token;
- if(!array_key_exists('v', $params)) $params['v'] = $this->v;
- $ch = curl_init(self::URL.$method);
- curl_setopt_array($ch, array(
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $params
- ));
- $resp = curl_exec($ch);
- curl_close($ch);
- return json_decode($resp, !$obj);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment