Класс vkapi- скачан с vk.com и подогнан под фреймворк, ничего не изменялось.
<?php
namespace Model;
class Vkapi extends \Model {
var $api_secret;
var $app_id;
var $api_url;
function __construct($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);
}
}
?>
Ответ:Array ( [error] => Array ( [error_code] => 4 [error_msg] => Incorrect signature: Session can be expired, revoked by user or connected with different IP address [request_params] => Array ( [0] => Array ( [key] => api_id [value] => 3300219 ) [1] => Array ( [key] => format [value] => json ) [2] => Array ( [key] => gid [value] => 48852036 ) [3] => Array ( [key] => method [value] => photos.getWallUploadServer ) [4] => Array ( [key] => random [value] => 5328 ) [5] => Array ( [key] => timestamp [value] => 1362576280 ) [6] => Array ( [key] => v [value] => 3.0 ) [7] => Array ( [key] => sig [value] => e7b98d0fba8d9bc023ba1964054a3f77 ) ) ) )
Изменил: Андрей (06.03.2013 / 17:47)