Created
September 20, 2012 12:54
-
-
Save krll-k/3755715 to your computer and use it in GitHub Desktop.
get friendslist/grouplist php vkapoi
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
<? | |
$start_time = microtime(1); | |
require 'vkapi.class.php'; | |
require 'vkapi.miniclass.php'; | |
VK_auth(); | |
$api_id = 2866913; | |
$secret_key = 'UCk5eCa90GsKeeDKbgHT'; | |
$VK = new vkapi($api_id, $secret_key); | |
$friendlist = $VK->api('friends.get', array('uid'=>jimmy_photo,'access_token'=>$access_get->access_token)); | |
$grouplist = $VK->api('groups.getMembers', array('gid'=>'26599838','access_token'=>$access_get->access_token)); | |
print_r($friendlist);print_r($grouplist); | |
echo microtime(1)-$start_time; | |
?> |
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 | |
/** | |
* VKAPI class for vk.com social network | |
* | |
* @package server API methods | |
* @link http://vk.com/developers.php | |
* @autor Oleg Illarionov | |
* @version 1.0 | |
*/ | |
class vkapi { | |
var $api_secret; | |
var $app_id; | |
var $api_url; | |
function vkapi($app_id, $api_secret, $api_url = 'api.vk.com/api.php') { | |
$this->app_id = $app_id; | |
$this->api_secret = $api_secret; | |
if (!strstr($api_url, 'http://')) $api_url = 'http://'.$api_url; | |
$this->api_url = $api_url; | |
} | |
function api($method,$params=false) { | |
if (!$params) $params = array(); | |
$params['api_id'] = $this->app_id; | |
$params['v'] = '3.0'; | |
$params['method'] = $method; | |
$params['timestamp'] = time(); | |
$params['format'] = 'json'; | |
$params['random'] = rand(0,10000); | |
ksort($params); | |
$sig = ''; | |
foreach($params as $k=>$v) { | |
$sig .= $k.'='.$v; | |
} | |
$sig .= $this->api_secret; | |
$params['sig'] = md5($sig); | |
$query = $this->api_url.'?'.$this->params($params); | |
$res = file_get_contents($query); | |
return json_decode($res, true); | |
} | |
function params($params) { | |
$pice = array(); | |
foreach($params as $k=>$v) { | |
$pice[] = $k.'='.urlencode($v); | |
} | |
return implode('&',$pice); | |
} | |
} | |
?> |
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
<? | |
function VK_auth(){ | |
error_reporting(0); | |
$api_id = 2866913; | |
$secret_key = 'UCk5eCa90GsKeeDKbgHT'; | |
$scope = 999998; | |
$display = 'popup'; | |
$redirect_uri = $_SERVER['SERVER_ADDR']; | |
$authorize = 'http://oauth.vk.com/authorize?'.http_build_query(array( | |
'client_id' => $api_id, | |
'scope' => $scope, | |
'display' => $display, | |
'redirect_uri' => $redirect_uri)); | |
$access_get = 'https://oauth.vk.com/access_token?'.http_build_query(array( | |
'client_id' => $api_id, | |
'client_secret' => $secret_key, | |
'redirect_uri' => $redirect_uri, | |
'code' => $_REQUEST['code'])); | |
$access_get = file_get_contents($access_get); | |
$access_get = json_decode($access_get); | |
print_r($access_get); | |
if ($access_get->user_id==null) header("Location:".$authorize); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment